def calc_k_constP(P):
    tmp_total_w = 0
    tmp_k = 1
    for w in w_s:
        tmp_total_w += w
        if tmp_total_w > P:
            tmp_k += 1
            tmp_total_w = w

    return tmp_k

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

max_w = max(w_s)

left, right = max_w, 10000 * n
while left < right:
    mid = (right + left) // 2
    tmp_k = calc_k_constP(mid)
    if tmp_k <= k:
        right = mid
    else:
        left = mid + 1

print(left) def calc_k_constP(P):
    tmp_total_w = 0
    tmp_k = 1
    for w in w_s:
        tmp_total_w += w
        if tmp_total_w > P:
            tmp_k += 1
            tmp_total_w = w

    return tmp_k calc_k_constP tmp_total_w = 0 tmp_total_w 0 tmp_k = 1 tmp_k 1 for w in w_s:
        tmp_total_w += w
        if tmp_total_w > P:
            tmp_k += 1
            tmp_total_w = w

     w w_s tmp_total_w += w tmp_total_w w if tmp_total_w > P:
            tmp_k += 1
            tmp_total_w = w

     tmp_total_w > P tmp_total_w P tmp_k += 1 tmp_k 1 tmp_total_w = w tmp_total_w w return tmp_k tmp_k P P 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_s = [int(input()) for i in range(n)] w_s [int(input()) for i in range(n)] max_w = max(w_s) max_w max(w_s) max w_s left, right = max_w, 10000 * n left max_w right 10000 * n 10000 n while left < right:
    mid = (right + left) // 2
    tmp_k = calc_k_constP(mid)
    if tmp_k <= k:
        right = mid
    else:
        left = mid + 1 left < right left right mid = (right + left) // 2 mid (right + left) // 2 right + left right left 2 tmp_k = calc_k_constP(mid) tmp_k calc_k_constP(mid) calc_k_constP mid if tmp_k <= k:
        right = mid
    else:
        left = mid + 1 tmp_k <= k tmp_k k right = mid right mid left = mid + 1 left mid + 1 mid 1 print(left) print left n, k = map(int, input().split(' ')) map(int, input().split(' ')) n right = max_w, 10000 * n 10000 * n right tmp_k = calc_k_constP(mid) calc_k_constP(mid) tmp_k max_w = max(w_s) max(w_s) max_w left = mid + 1 mid + 1 left def calc_k_constP(P):
    tmp_total_w = 0
    tmp_k = 1
    for w in w_s:
        tmp_total_w += w
        if tmp_total_w > P:
            tmp_k += 1
            tmp_total_w = w

    return tmp_k def calc_k_constP(P):
    tmp_total_w = 0
    tmp_k = 1
    for w in w_s:
        tmp_total_w += w
        if tmp_total_w > P:
            tmp_k += 1
            tmp_total_w = w

    return tmp_k calc_k_constP right = mid mid right k = map(int, input().split(' ')) map(int, input().split(' ')) k w_s = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w_s left, right = max_w, 10000 * n max_w left mid = (right + left) // 2 (right + left) // 2 mid
def calc_k_constP(P):
    tmp_total_w = 0
    tmp_k = 1
    for w in w_s:
        tmp_total_w += w
        if tmp_total_w > P:
            tmp_k += 1
            tmp_total_w = w

    return tmp_k

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

max_w = max(w_s)

left, right = max_w, 10000 * n
while left < right:
    mid = (right + left) // 2
    tmp_k = calc_k_constP(mid)
    if tmp_k <= k:
        right = mid
    else:
        left = mid + 1

print(left)
