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

def f(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

left = 0
right = 100000 * 10000

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

def f(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

left = 0
right = 100000 * 10000

while right - left > 1:
    mid = (left + right) // 2
    v = f(mid)
    if v>=n:right=mid
    else: left = mid
print (right)