def luggage_num(P):
    i = 0
    for _ in range(k):
        t = 0
        while t + w[i] <= P:
            t += w[i]
            i += 1
            if i == n:
                return n
    return i

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

right = n * max(w)
left = 0

while right - left > 1:
    mid = int((right + left) / 2)
    if luggage_num(mid) >= n:
        right = mid
    else:
        left = mid
print(right) def luggage_num(P):
    i = 0
    for _ in range(k):
        t = 0
        while t + w[i] <= P:
            t += w[i]
            i += 1
            if i == n:
                return n
    return i luggage_num i = 0 i 0 for _ in range(k):
        t = 0
        while t + w[i] <= P:
            t += w[i]
            i += 1
            if i == n:
                return n
     _ range(k) range k t = 0 t 0 while t + w[i] <= P:
            t += w[i]
            i += 1
            if i == n:
                return n
     t + w[i] <= P t + w[i] t w[i] w i P t += w[i] t w[i] w i i += 1 i 1 if i == n:
                return n
     i == n i n return n n return i i P P n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k w = [] w [] for _ in range(n):
    w.append(int(input())) _ range(n) range n w.append(int(input())) w.append w append int(input()) int input() input right = n * max(w) right n * max(w) n max(w) max w left = 0 left 0 while right - left > 1:
    mid = int((right + left) / 2)
    if luggage_num(mid) >= 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 if luggage_num(mid) >= n:
        right = mid
    else:
        left = mid luggage_num(mid) >= n luggage_num(mid) luggage_num mid n right = mid right mid left = mid left mid print(right) print right mid = int((right + left) / 2) int((right + left) / 2) mid n, k = map(int, input().split()) map(int, input().split()) n left = mid mid left w = [] [] w right = mid mid right right = n * max(w) n * max(w) right left = 0 0 left k = map(int, input().split()) map(int, input().split()) k def luggage_num(P):
    i = 0
    for _ in range(k):
        t = 0
        while t + w[i] <= P:
            t += w[i]
            i += 1
            if i == n:
                return n
    return i def luggage_num(P):
    i = 0
    for _ in range(k):
        t = 0
        while t + w[i] <= P:
            t += w[i]
            i += 1
            if i == n:
                return n
    return i luggage_num
def luggage_num(P):
    i = 0
    for _ in range(k):
        t = 0
        while t + w[i] <= P:
            t += w[i]
            i += 1
            if i == n:
                return n
    return i

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

right = n * max(w)
left = 0

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