def check(P, k, n, T):
    res = 0
    for _ in range(k):
        s = 0
        while s + T[res] <= P:
            s += T[res]
            res += 1
            if res == n:
                return n
    return res

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

left = 0
right = n * 10000
mid = (left + right) // 2
while right - left > 1:
    v = check(mid, k, n, w)
    if v == n:
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right) def check(P, k, n, T):
    res = 0
    for _ in range(k):
        s = 0
        while s + T[res] <= P:
            s += T[res]
            res += 1
            if res == n:
                return n
    return res check res = 0 res 0 for _ in range(k):
        s = 0
        while s + T[res] <= P:
            s += T[res]
            res += 1
            if res == n:
                return n
     _ range(k) range k s = 0 s 0 while s + T[res] <= P:
            s += T[res]
            res += 1
            if res == n:
                return n
     s + T[res] <= P s + T[res] s T[res] T res P s += T[res] s T[res] T res res += 1 res 1 if res == n:
                return n
     res == n res n return n n return res res P P k k n n T T 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 = 0 left 0 right = n * 10000 right n * 10000 n 10000 mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 while right - left > 1:
    v = check(mid, k, n, w)
    if v == n:
        right = mid
    else:
        left = mid
    mid = (left + right) // 2 right - left > 1 right - left right left 1 v = check(mid, k, n, w) v check(mid, k, n, w) check mid k n w if v == n:
        right = mid
    else:
        left = mid
     v == n v n right = mid right mid left = mid left mid mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 print(right) print right def check(P, k, n, T):
    res = 0
    for _ in range(k):
        s = 0
        while s + T[res] <= P:
            s += T[res]
            res += 1
            if res == n:
                return n
    return res def check(P, k, n, T):
    res = 0
    for _ in range(k):
        s = 0
        while s + T[res] <= P:
            s += T[res]
            res += 1
            if res == n:
                return n
    return res check right = mid mid right w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w k = map(int, input().split()) map(int, input().split()) k right = n * 10000 n * 10000 right v = check(mid, k, n, w) check(mid, k, n, w) v left = 0 0 left mid = (left + right) // 2 (left + right) // 2 mid n, k = map(int, input().split()) map(int, input().split()) n left = mid mid left mid = (left + right) // 2 (left + right) // 2 mid
def check(P, k, n, T):
    res = 0
    for _ in range(k):
        s = 0
        while s + T[res] <= P:
            s += T[res]
            res += 1
            if res == n:
                return n
    return res

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

left = 0
right = n * 10000
mid = (left + right) // 2
while right - left > 1:
    v = check(mid, k, n, w)
    if v == n:
        right = mid
    else:
        left = mid
    mid = (left + right) // 2
print(right)
