n, k = map(int, input().split())
truck = [0] * k
w = []

for _ in range(n):
    w.append(int(input()))


def is_ok(p):
    truck_index = 0
    w_index = 0
    while w_index < n and truck_index < k:
        load_sum = 0
        while w_index < n and load_sum + w[w_index] <= p:
            load_sum += w[w_index]
            w_index += 1
        truck_index += 1
    return w_index == n


ng = 0
ok = 100000 * 100000

while ok - ng > 1:
    mid = (ng + ok) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid

print("%d" % ok)
 n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k truck = [0] * k truck [0] * k [0] 0 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 def is_ok(p):
    truck_index = 0
    w_index = 0
    while w_index < n and truck_index < k:
        load_sum = 0
        while w_index < n and load_sum + w[w_index] <= p:
            load_sum += w[w_index]
            w_index += 1
        truck_index += 1
    return w_index == n is_ok truck_index = 0 truck_index 0 w_index = 0 w_index 0 while w_index < n and truck_index < k:
        load_sum = 0
        while w_index < n and load_sum + w[w_index] <= p:
            load_sum += w[w_index]
            w_index += 1
        truck_index += 1
     w_index < n and truck_index < k w_index < n w_index n truck_index < k truck_index k load_sum = 0 load_sum 0 while w_index < n and load_sum + w[w_index] <= p:
            load_sum += w[w_index]
            w_index += 1
         w_index < n and load_sum + w[w_index] <= p w_index < n w_index n load_sum + w[w_index] <= p load_sum + w[w_index] load_sum w[w_index] w w_index p load_sum += w[w_index] load_sum w[w_index] w w_index w_index += 1 w_index 1 truck_index += 1 truck_index 1 return w_index == n w_index == n w_index n p p ng = 0 ng 0 ok = 100000 * 100000 ok 100000 * 100000 100000 100000 while ok - ng > 1:
    mid = (ng + ok) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid ok - ng > 1 ok - ng ok ng 1 mid = (ng + ok) // 2 mid (ng + ok) // 2 ng + ok ng ok 2 if is_ok(mid):
        ok = mid
    else:
        ng = mid is_ok(mid) is_ok mid ok = mid ok mid ng = mid ng mid print("%d" % ok) print "%d" % ok "%d" ok ok = mid mid ok ng = mid mid ng ng = 0 0 ng ok = 100000 * 100000 100000 * 100000 ok def is_ok(p):
    truck_index = 0
    w_index = 0
    while w_index < n and truck_index < k:
        load_sum = 0
        while w_index < n and load_sum + w[w_index] <= p:
            load_sum += w[w_index]
            w_index += 1
        truck_index += 1
    return w_index == n def is_ok(p):
    truck_index = 0
    w_index = 0
    while w_index < n and truck_index < k:
        load_sum = 0
        while w_index < n and load_sum + w[w_index] <= p:
            load_sum += w[w_index]
            w_index += 1
        truck_index += 1
    return w_index == n is_ok n, k = map(int, input().split()) map(int, input().split()) n w = [] [] w k = map(int, input().split()) map(int, input().split()) k truck = [0] * k [0] * k truck mid = (ng + ok) // 2 (ng + ok) // 2 mid
n, k = map(int, input().split())
truck = [0] * k
w = []

for _ in range(n):
    w.append(int(input()))


def is_ok(p):
    truck_index = 0
    w_index = 0
    while w_index < n and truck_index < k:
        load_sum = 0
        while w_index < n and load_sum + w[w_index] <= p:
            load_sum += w[w_index]
            w_index += 1
        truck_index += 1
    return w_index == n


ng = 0
ok = 100000 * 100000

while ok - ng > 1:
    mid = (ng + ok) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid

print("%d" % ok)

