import sys
def f(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=list(map(int,sys.stdin.read().splitlines()))
l=0;r=n*100000
while r-l>1:
 m=(l+r)//2
 if f(m)>=n:r=m
 else:l=m
print(r) import sys sys def f(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 f 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 w=list(map(int,sys.stdin.read().splitlines())) w list(map(int,sys.stdin.read().splitlines())) list map(int,sys.stdin.read().splitlines()) map int sys.stdin.read().splitlines() sys.stdin.read().splitlines sys.stdin.read() sys.stdin.read sys.stdin sys stdin read splitlines l=0 l 0 r=n*100000 r n*100000 n 100000 while r-l>1:
 m=(l+r)//2
 if f(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 f(m)>=n:r=m
 else:l=m f(m)>=n f(m) f m n print(r) print r def f(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 f(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 f k=map(int,input().split()) map(int,input().split()) k w=list(map(int,sys.stdin.read().splitlines())) list(map(int,sys.stdin.read().splitlines())) w l=0 0 l m=(l+r)//2 (l+r)//2 m n,k=map(int,input().split()) map(int,input().split()) n r=n*100000 n*100000 r
import sys
def f(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=list(map(int,sys.stdin.read().splitlines()))
l=0;r=n*100000
while r-l>1:
 m=(l+r)//2
 if f(m)>=n:r=m
 else:l=m
print(r)
