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

print(right)
