n, k = map(int, input().split())
W = [int(input()) for _ in range(n)]
def can_load(W, k, q, n):
    i = 0
    for _ in range(k):
        s = 0
        while i < n and s + W[i] <= q:
            s += W[i]
            i += 1
    if i == n:
        return True
    else:
        return False

# 積載量をmidと仮定して二分探索
hi = 10 ** 9  # OK
lo = 0  # NG
while hi - lo > 1:
    mid = (hi + lo) // 2
    if can_load(W, k, mid, n):
        hi = mid
    else:
        lo = mid
print(hi) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input W = [int(input()) for _ in range(n)] W [int(input()) for _ in range(n)] def can_load(W, k, q, n):
    i = 0
    for _ in range(k):
        s = 0
        while i < n and s + W[i] <= q:
            s += W[i]
            i += 1
    if i == n:
        return True
    else:
        return False

# 積載量をmidと仮定して二分探索 can_load i = 0 i 0 for _ in range(k):
        s = 0
        while i < n and s + W[i] <= q:
            s += W[i]
            i += 1
     _ range(k) range k s = 0 s 0 while i < n and s + W[i] <= q:
            s += W[i]
            i += 1
     i < n and s + W[i] <= q i < n i n s + W[i] <= q s + W[i] s W[i] W i q s += W[i] s W[i] W i i += 1 i 1 if i == n:
        return True
    else:
        return False

# 積載量をmidと仮定して二分探索 i == n i n return True True return False False W W k k q q n n hi = 10 ** 9 hi 10 ** 9 10 9 lo = 0 lo 0 while hi - lo > 1:
    mid = (hi + lo) // 2
    if can_load(W, k, mid, n):
        hi = mid
    else:
        lo = mid hi - lo > 1 hi - lo hi lo 1 mid = (hi + lo) // 2 mid (hi + lo) // 2 hi + lo hi lo 2 if can_load(W, k, mid, n):
        hi = mid
    else:
        lo = mid can_load(W, k, mid, n) can_load W k mid n hi = mid hi mid lo = mid lo mid print(hi) print hi mid = (hi + lo) // 2 (hi + lo) // 2 mid k = map(int, input().split()) map(int, input().split()) k hi = mid mid hi lo = 0 0 lo n, k = map(int, input().split()) map(int, input().split()) n hi = 10 ** 9 10 ** 9 hi lo = mid mid lo W = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] W def can_load(W, k, q, n):
    i = 0
    for _ in range(k):
        s = 0
        while i < n and s + W[i] <= q:
            s += W[i]
            i += 1
    if i == n:
        return True
    else:
        return False

# 積載量をmidと仮定して二分探索 def can_load(W, k, q, n):
    i = 0
    for _ in range(k):
        s = 0
        while i < n and s + W[i] <= q:
            s += W[i]
            i += 1
    if i == n:
        return True
    else:
        return False

# 積載量をmidと仮定して二分探索 can_load
n, k = map(int, input().split())
W = [int(input()) for _ in range(n)]
def can_load(W, k, q, n):
    i = 0
    for _ in range(k):
        s = 0
        while i < n and s + W[i] <= q:
            s += W[i]
            i += 1
    if i == n:
        return True
    else:
        return False

# 積載量をmidと仮定して二分探索
hi = 10 ** 9  # OK
lo = 0  # NG
while hi - lo > 1:
    mid = (hi + lo) // 2
    if can_load(W, k, mid, n):
        hi = mid
    else:
        lo = mid
print(hi)
