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

# 最大積載量をPとした時, k台のトラックでどの荷物まで積めるのか
def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: return n
    return i

# 2分探索する
def solve():
    left = 0
    right = 100000*10000
    mid = None
    while right - left > 1:
        mid = int((right + left)/2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right

ans = solve()
print(ans) n, k = list(map(int, input().split(' '))) n list(map(int, input().split(' '))) list 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)] def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: return n
    return i

# 2分探索する check i = 0 i 0 for j in range(k):
        s = 0
        while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: return n
     j range(k) range k s = 0 s 0 while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: return n
     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 if i == n: return n
     i == n i n return i i P P def solve():
    left = 0
    right = 100000*10000
    mid = None
    while right - left > 1:
        mid = int((right + left)/2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right solve left = 0 left 0 right = 100000*10000 right 100000*10000 100000 10000 mid = None mid None while right - left > 1:
        mid = int((right + left)/2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
     right - left > 1 right - left right left 1 mid = int((right + left)/2) mid int((right + left)/2) int (right + left)/2 right + left right left 2 v = check(mid) v check(mid) check mid if v >= n:
            right = mid
        else:
            left = mid
     v >= n v n right = mid right mid left = mid left mid return right right ans = solve() ans solve() solve print(ans) print ans n, k = list(map(int, input().split(' '))) list(map(int, input().split(' '))) n k = list(map(int, input().split(' '))) list(map(int, input().split(' '))) k W = [int(input()) for i in range(n)] [int(input()) for i in range(n)] W def solve():
    left = 0
    right = 100000*10000
    mid = None
    while right - left > 1:
        mid = int((right + left)/2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right def solve():
    left = 0
    right = 100000*10000
    mid = None
    while right - left > 1:
        mid = int((right + left)/2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right solve ans = solve() solve() ans def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: return n
    return i

# 2分探索する def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: return n
    return i

# 2分探索する check
n, k = list(map(int, input().split(' ')))
W = [int(input()) for i in range(n)]

# 最大積載量をPとした時, k台のトラックでどの荷物まで積めるのか
def check(P):
    i = 0
    for j in range(k):
        s = 0
        while s + W[i] <= P:
            s += W[i]
            i += 1
            if i == n: return n
    return i

# 2分探索する
def solve():
    left = 0
    right = 100000*10000
    mid = None
    while right - left > 1:
        mid = int((right + left)/2)
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right

ans = solve()
print(ans)
