n,k=map(int,input().split())
tmp=[int(input()) for i in range(n)]
 
left=max(tmp)-1
right=sum(tmp)
while left+1 < right:
    mid=(left+right)//2
    count=1
    now=0
    for i in tmp:
        if mid<now+i:
            now=i
            count+=1
        else:
            now+=i
 
    if count<=k:
        right=mid
    else:
        left=mid
print(right) 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 tmp=[int(input()) for i in range(n)] tmp [int(input()) for i in range(n)] left=max(tmp)-1 left max(tmp)-1 max(tmp) max tmp 1 right=sum(tmp) right sum(tmp) sum tmp while left+1 < right:
    mid=(left+right)//2
    count=1
    now=0
    for i in tmp:
        if mid<now+i:
            now=i
            count+=1
        else:
            now+=i
 
    if count<=k:
        right=mid
    else:
        left=mid left+1 < right left+1 left 1 right mid=(left+right)//2 mid (left+right)//2 left+right left right 2 count=1 count 1 now=0 now 0 for i in tmp:
        if mid<now+i:
            now=i
            count+=1
        else:
            now+=i
 
     i tmp if mid<now+i:
            now=i
            count+=1
        else:
            now+=i
 
     mid<now+i mid now+i now i now=i now i count+=1 count 1 now+=i now i if count<=k:
        right=mid
    else:
        left=mid count<=k count k right=mid right mid left=mid left mid print(right) print right n,k=map(int,input().split()) map(int,input().split()) n right=sum(tmp) sum(tmp) right now+=i i now right=mid mid right left=mid mid left mid=(left+right)//2 (left+right)//2 mid count=1 1 count count+=1 1 count k=map(int,input().split()) map(int,input().split()) k tmp=[int(input()) for i in range(n)] [int(input()) for i in range(n)] tmp now=i i now left=max(tmp)-1 max(tmp)-1 left now=0 0 now
n,k=map(int,input().split())
tmp=[int(input()) for i in range(n)]
 
left=max(tmp)-1
right=sum(tmp)
while left+1 < right:
    mid=(left+right)//2
    count=1
    now=0
    for i in tmp:
        if mid<now+i:
            now=i
            count+=1
        else:
            now+=i
 
    if count<=k:
        right=mid
    else:
        left=mid
print(right)
