n, k = map(int, input().split())
ws = []

def check(limit):
    idx_k = 0
    idx_n = 0
    temp = 0
    array = list(ws)

    while True:
        if idx_k == k or idx_n == n:
            break
        if temp + array[idx_n] <= limit:
            temp = temp + array[idx_n]
            idx_n += 1
        else:
            temp = 0
            idx_k += 1
    if idx_n < n:
        return False
    else:
        return True

for i in range(n):
    ws.append(int(input()))

limit = 1
left = 1
right = 100000 * 10000
mid = int((left + right) / 2)
ans = right

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

print(ans)

 n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k ws = [] ws [] def check(limit):
    idx_k = 0
    idx_n = 0
    temp = 0
    array = list(ws)

    while True:
        if idx_k == k or idx_n == n:
            break
        if temp + array[idx_n] <= limit:
            temp = temp + array[idx_n]
            idx_n += 1
        else:
            temp = 0
            idx_k += 1
    if idx_n < n:
        return False
    else:
        return True check idx_k = 0 idx_k 0 idx_n = 0 idx_n 0 temp = 0 temp 0 array = list(ws) array list(ws) list ws while True:
        if idx_k == k or idx_n == n:
            break
        if temp + array[idx_n] <= limit:
            temp = temp + array[idx_n]
            idx_n += 1
        else:
            temp = 0
            idx_k += 1
     True if idx_k == k or idx_n == n:
            break
         idx_k == k or idx_n == n idx_k == k idx_k k idx_n == n idx_n n break if temp + array[idx_n] <= limit:
            temp = temp + array[idx_n]
            idx_n += 1
        else:
            temp = 0
            idx_k += 1
     temp + array[idx_n] <= limit temp + array[idx_n] temp array[idx_n] array idx_n limit temp = temp + array[idx_n] temp temp + array[idx_n] temp array[idx_n] array idx_n idx_n += 1 idx_n 1 temp = 0 temp 0 idx_k += 1 idx_k 1 if idx_n < n:
        return False
    else:
        return True idx_n < n idx_n n return False False return True True limit limit for i in range(n):
    ws.append(int(input())) i range(n) range n ws.append(int(input())) ws.append ws append int(input()) int input() input limit = 1 limit 1 left = 1 left 1 right = 100000 * 10000 right 100000 * 10000 100000 10000 mid = int((left + right) / 2) mid int((left + right) / 2) int (left + right) / 2 left + right left right 2 ans = right ans right while left <= right:
    if check(mid):
        ans = mid
        right = mid-1
        mid  = (left + right) // 2
    else:
        left = mid+1
        mid = (left + right) // 2 left <= right left right if check(mid):
        ans = mid
        right = mid-1
        mid  = (left + right) // 2
    else:
        left = mid+1
        mid = (left + right) // 2 check(mid) check mid ans = mid ans mid right = mid-1 right mid-1 mid 1 mid  = (left + right) // 2 mid (left + right) // 2 left + right left right 2 left = mid+1 left mid+1 mid 1 mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 print(ans) print ans right = mid-1 mid-1 right mid  = (left + right) // 2 (left + right) // 2 mid n, k = map(int, input().split()) map(int, input().split()) n left = mid+1 mid+1 left mid = (left + right) // 2 (left + right) // 2 mid def check(limit):
    idx_k = 0
    idx_n = 0
    temp = 0
    array = list(ws)

    while True:
        if idx_k == k or idx_n == n:
            break
        if temp + array[idx_n] <= limit:
            temp = temp + array[idx_n]
            idx_n += 1
        else:
            temp = 0
            idx_k += 1
    if idx_n < n:
        return False
    else:
        return True def check(limit):
    idx_k = 0
    idx_n = 0
    temp = 0
    array = list(ws)

    while True:
        if idx_k == k or idx_n == n:
            break
        if temp + array[idx_n] <= limit:
            temp = temp + array[idx_n]
            idx_n += 1
        else:
            temp = 0
            idx_k += 1
    if idx_n < n:
        return False
    else:
        return True check right = 100000 * 10000 100000 * 10000 right left = 1 1 left ans = mid mid ans limit = 1 1 limit ans = right right ans ws = [] [] ws k = map(int, input().split()) map(int, input().split()) k mid = int((left + right) / 2) int((left + right) / 2) mid
n, k = map(int, input().split())
ws = []

def check(limit):
    idx_k = 0
    idx_n = 0
    temp = 0
    array = list(ws)

    while True:
        if idx_k == k or idx_n == n:
            break
        if temp + array[idx_n] <= limit:
            temp = temp + array[idx_n]
            idx_n += 1
        else:
            temp = 0
            idx_k += 1
    if idx_n < n:
        return False
    else:
        return True

for i in range(n):
    ws.append(int(input()))

limit = 1
left = 1
right = 100000 * 10000
mid = int((left + right) / 2)
ans = right

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

print(ans)


