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

left = max(W)
ans = right = 100000 * 100000


def is_ok(P):
    truck = 1
    t_sum = 0
    for i in range(n):
        if t_sum + W[i] <= P:
            t_sum += W[i]
        else:
            truck += 1
            t_sum = W[i]
            if truck > k:
                return False
    return True


while left <= right:
    mid = (left + right) // 2
    if is_ok(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1

print(ans)
 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)] left = max(W) left max(W) max W ans = right = 100000 * 100000 ans 100000 * 100000 100000 100000 = right = 100000 * 100000 right 100000 * 100000 def is_ok(P):
    truck = 1
    t_sum = 0
    for i in range(n):
        if t_sum + W[i] <= P:
            t_sum += W[i]
        else:
            truck += 1
            t_sum = W[i]
            if truck > k:
                return False
    return True is_ok truck = 1 truck 1 t_sum = 0 t_sum 0 for i in range(n):
        if t_sum + W[i] <= P:
            t_sum += W[i]
        else:
            truck += 1
            t_sum = W[i]
            if truck > k:
                return False
     i range(n) range n if t_sum + W[i] <= P:
            t_sum += W[i]
        else:
            truck += 1
            t_sum = W[i]
            if truck > k:
                return False
     t_sum + W[i] <= P t_sum + W[i] t_sum W[i] W i P t_sum += W[i] t_sum W[i] W i truck += 1 truck 1 t_sum = W[i] t_sum W[i] W i if truck > k:
                return False
     truck > k truck k return False False return True True P P while left <= right:
    mid = (left + right) // 2
    if is_ok(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1 left <= right left right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 if is_ok(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1 is_ok(mid) is_ok mid ans = mid ans mid right = mid - 1 right mid - 1 mid 1 left = mid + 1 left mid + 1 mid 1 print(ans) print ans n, k = map(int, input().split()) map(int, input().split()) n left = max(W) max(W) left def is_ok(P):
    truck = 1
    t_sum = 0
    for i in range(n):
        if t_sum + W[i] <= P:
            t_sum += W[i]
        else:
            truck += 1
            t_sum = W[i]
            if truck > k:
                return False
    return True def is_ok(P):
    truck = 1
    t_sum = 0
    for i in range(n):
        if t_sum + W[i] <= P:
            t_sum += W[i]
        else:
            truck += 1
            t_sum = W[i]
            if truck > k:
                return False
    return True is_ok right = mid - 1 mid - 1 right ans = right = 100000 * 100000 100000 * 100000 ans right = 100000 * 100000 100000 * 100000 right left = mid + 1 mid + 1 left k = map(int, input().split()) map(int, input().split()) k ans = mid mid ans mid = (left + right) // 2 (left + right) // 2 mid W = [int(input()) for i in range(n)] [int(input()) for i in range(n)] W
n, k = map(int, input().split())
W = [int(input()) for i in range(n)]

left = max(W)
ans = right = 100000 * 100000


def is_ok(P):
    truck = 1
    t_sum = 0
    for i in range(n):
        if t_sum + W[i] <= P:
            t_sum += W[i]
        else:
            truck += 1
            t_sum = W[i]
            if truck > k:
                return False
    return True


while left <= right:
    mid = (left + right) // 2
    if is_ok(mid):
        ans = mid
        right = mid - 1
    else:
        left = mid + 1

print(ans)

