n,k=map(int,input().split())
w=[int(input()) for i in range(n)]
def ok(p):
  t=[0]*k
  curr=0
  for i in w:
    if i>p:
      return False
    if t[curr]+i>p:
      curr+=1
      if curr>=k:
        return False
    t[curr]+=i
  return True
l=0
h=10**9+1
while True:
  if l>=h:
    print(l)
    break
  if h==l+1:
    print(l if ok(l) else h)
    break
  mid=(l+h)//2
  if ok(mid):
    h=mid
  else:
    l=mid
 n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input w=[int(input()) for i in range(n)] w [int(input()) for i in range(n)] def ok(p):
  t=[0]*k
  curr=0
  for i in w:
    if i>p:
      return False
    if t[curr]+i>p:
      curr+=1
      if curr>=k:
        return False
    t[curr]+=i
  return True ok t=[0]*k t [0]*k [0] 0 k curr=0 curr 0 for i in w:
    if i>p:
      return False
    if t[curr]+i>p:
      curr+=1
      if curr>=k:
        return False
    t[curr]+=i
   i w if i>p:
      return False
     i>p i p return False False if t[curr]+i>p:
      curr+=1
      if curr>=k:
        return False
     t[curr]+i>p t[curr]+i t[curr] t curr i p curr+=1 curr 1 if curr>=k:
        return False
     curr>=k curr k return False False t[curr]+=i t[curr] t curr i return True True p p l=0 l 0 h=10**9+1 h 10**9+1 10**9 10 9 1 while True:
  if l>=h:
    print(l)
    break
  if h==l+1:
    print(l if ok(l) else h)
    break
  mid=(l+h)//2
  if ok(mid):
    h=mid
  else:
    l=mid True if l>=h:
    print(l)
    break
   l>=h l h print(l) print l break if h==l+1:
    print(l if ok(l) else h)
    break
   h==l+1 h l+1 l 1 print(l if ok(l) else h) print l if ok(l) else h ok(l) ok l l h break mid=(l+h)//2 mid (l+h)//2 l+h l h 2 if ok(mid):
    h=mid
  else:
    l=mid ok(mid) ok mid h=mid h mid l=mid l mid h=10**9+1 10**9+1 h def ok(p):
  t=[0]*k
  curr=0
  for i in w:
    if i>p:
      return False
    if t[curr]+i>p:
      curr+=1
      if curr>=k:
        return False
    t[curr]+=i
  return True def ok(p):
  t=[0]*k
  curr=0
  for i in w:
    if i>p:
      return False
    if t[curr]+i>p:
      curr+=1
      if curr>=k:
        return False
    t[curr]+=i
  return True ok l=0 0 l mid=(l+h)//2 (l+h)//2 mid h=mid mid h l=mid mid l n,k=map(int,input().split()) map(int,input().split()) n k=map(int,input().split()) map(int,input().split()) k w=[int(input()) for i in range(n)] [int(input()) for i in range(n)] w
n,k=map(int,input().split())
w=[int(input()) for i in range(n)]
def ok(p):
  t=[0]*k
  curr=0
  for i in w:
    if i>p:
      return False
    if t[curr]+i>p:
      curr+=1
      if curr>=k:
        return False
    t[curr]+=i
  return True
l=0
h=10**9+1
while True:
  if l>=h:
    print(l)
    break
  if h==l+1:
    print(l if ok(l) else h)
    break
  mid=(l+h)//2
  if ok(mid):
    h=mid
  else:
    l=mid

