def check(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i
n,k=map(int,input().split())
w=[int(input())for _ in[0]*n]
l=0;r=n*100000
while r-l>1:
 m=(l+r)//2
 if check(m)>=n:r=m
 else:l=m
print(r) def check(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i check i=0 i 0 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
  _ [0]*k [0] 0 k s=0 s 0 while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
  s+w[i]<=P s+w[i] s w[i] w i P s+=w[i] s w[i] w i i+=1 i 1 if i==n: return n
  i==n i n return i i P P n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k int(input())for _ in[0]*n for _ in[0]*n _ [0]*n [0] 0 n for _ in[0]*n int(input()) int input() input w=[int(input())for _ in[0]*n] w [int(input())for _ in[0]*n] l=0 l 0 r=n*100000 r n*100000 n 100000 while r-l>1:
 m=(l+r)//2
 if check(m)>=n:r=m
 else:l=m r-l>1 r-l r l 1 m=(l+r)//2 m (l+r)//2 l+r l r 2 if check(m)>=n:r=m
 else:l=m check(m)>=n check(m) check m n print(r) print r r=n*100000 n*100000 r l=0 0 l def check(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i def check(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i check 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 _ in[0]*n] [int(input())for _ in[0]*n] w m=(l+r)//2 (l+r)//2 m
def check(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i
n,k=map(int,input().split())
w=[int(input())for _ in[0]*n]
l=0;r=n*100000
while r-l>1:
 m=(l+r)//2
 if check(m)>=n:r=m
 else:l=m
print(r)
