n,k = map(int,input().split())
w = [int(input()) for _ in range(n)]
left = max(w)-1
right = sum(w)

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

while (right - left) > 1:
    mid = (left + right)//2
    count = 1
    c = 0
    for s in w:
        if mid < c + s:
            c = s
            count += 1
        else:
            c += s
    if count <= k:
        right = mid
    else:
        left = mid
print(right)
