def f(p, k, W):
    i = 0
    t = 0
    s = 0
    while i < len(W) and t < k:
        if s + W[i] <= p:
            s += W[i]
            i += 1
        else:
            s = 0
            t += 1
    return i


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

l = 0
r = 100000 * 10000 // k
while r - l > 1:
    mid = (l + r) // 2
    v = f(mid, k, W)
    if v >= n:
        r = mid
    else:
        l = mid

print(r)
 def f(p, k, W):
    i = 0
    t = 0
    s = 0
    while i < len(W) and t < k:
        if s + W[i] <= p:
            s += W[i]
            i += 1
        else:
            s = 0
            t += 1
    return i f i = 0 i 0 t = 0 t 0 s = 0 s 0 while i < len(W) and t < k:
        if s + W[i] <= p:
            s += W[i]
            i += 1
        else:
            s = 0
            t += 1
     i < len(W) and t < k i < len(W) i len(W) len W t < k t k if s + W[i] <= p:
            s += W[i]
            i += 1
        else:
            s = 0
            t += 1
     s + W[i] <= p s + W[i] s W[i] W i p s += W[i] s W[i] W i i += 1 i 1 s = 0 s 0 t += 1 t 1 return i i p p k k W W 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)] l = 0 l 0 r = 100000 * 10000 // k r 100000 * 10000 // k 100000 * 10000 100000 10000 k while r - l > 1:
    mid = (l + r) // 2
    v = f(mid, k, W)
    if v >= n:
        r = mid
    else:
        l = mid r - l > 1 r - l r l 1 mid = (l + r) // 2 mid (l + r) // 2 l + r l r 2 v = f(mid, k, W) v f(mid, k, W) f mid k W if v >= n:
        r = mid
    else:
        l = mid v >= n v n r = mid r mid l = mid l mid print(r) print r l = mid mid l def f(p, k, W):
    i = 0
    t = 0
    s = 0
    while i < len(W) and t < k:
        if s + W[i] <= p:
            s += W[i]
            i += 1
        else:
            s = 0
            t += 1
    return i def f(p, k, W):
    i = 0
    t = 0
    s = 0
    while i < len(W) and t < k:
        if s + W[i] <= p:
            s += W[i]
            i += 1
        else:
            s = 0
            t += 1
    return i f k = map(int, input().split()) map(int, input().split()) k r = 100000 * 10000 // k 100000 * 10000 // k r W = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] W n, k = map(int, input().split()) map(int, input().split()) n v = f(mid, k, W) f(mid, k, W) v mid = (l + r) // 2 (l + r) // 2 mid r = mid mid r l = 0 0 l
def f(p, k, W):
    i = 0
    t = 0
    s = 0
    while i < len(W) and t < k:
        if s + W[i] <= p:
            s += W[i]
            i += 1
        else:
            s = 0
            t += 1
    return i


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

l = 0
r = 100000 * 10000 // k
while r - l > 1:
    mid = (l + r) // 2
    v = f(mid, k, W)
    if v >= n:
        r = mid
    else:
        l = mid

print(r)

