n, k = map(int, input().split())
T = [int(input()) for i in range(n)]

def update(P):

    i=0
    for j in range(k):
        s=0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if(i == n):
                return n

    return i

left = 0
right = 1e+9

while right - left > 1:
    mid = int((left+right)/2)

    v = update(mid)
    if(v >= n):
        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 T = [int(input()) for i in range(n)] T [int(input()) for i in range(n)] def update(P):

    i=0
    for j in range(k):
        s=0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if(i == n):
                return n

    return i update i=0 i 0 for j in range(k):
        s=0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if(i == n):
                return n

     j range(k) range k s=0 s 0 while s + T[i] <= P:
            s += T[i]
            i += 1
            if(i == n):
                return n

     s + T[i] <= P s + T[i] s T[i] T i P s += T[i] s T[i] T i i += 1 i 1 if(i == n):
                return n

     i == n i n return n n return i i P P left = 0 left 0 right = 1e+9 right 1e+9 while right - left > 1:
    mid = int((left+right)/2)

    v = update(mid)
    if(v >= n):
        right = mid
    else:
            left = mid right - left > 1 right - left right left 1 mid = int((left+right)/2) mid int((left+right)/2) int (left+right)/2 left+right left right 2 v = update(mid) v update(mid) update mid if(v >= n):
        right = mid
    else:
            left = mid v >= n v n right = mid right mid left = mid left mid print(right) print right n, k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k left = mid mid left v = update(mid) update(mid) v left = 0 0 left def update(P):

    i=0
    for j in range(k):
        s=0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if(i == n):
                return n

    return i def update(P):

    i=0
    for j in range(k):
        s=0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if(i == n):
                return n

    return i update right = mid mid right mid = int((left+right)/2) int((left+right)/2) mid T = [int(input()) for i in range(n)] [int(input()) for i in range(n)] T right = 1e+9 1e+9 right
n, k = map(int, input().split())
T = [int(input()) for i in range(n)]

def update(P):

    i=0
    for j in range(k):
        s=0
        while s + T[i] <= P:
            s += T[i]
            i += 1
            if(i == n):
                return n

    return i

left = 0
right = 1e+9

while right - left > 1:
    mid = int((left+right)/2)

    v = update(mid)
    if(v >= n):
        right = mid
    else:
            left = mid

print(right)
