In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
n, k = map(int, input().split())
w = [int(input()) for i in range(n)]
l = max(w)
r = sum(w)

while l < r:
    m = (l + r) / 2
    stack = 0
    car = 0
    for i in w:
        stack += i
        if stack > m:
            stack = i
            car += 1
        if car < k:
            r = m
        else:
            l = m + 1
print(l)
import sys

n, k = map(int, input().split())
w = [int(sys.stdin.readline()) for i in range(n)]
l = max(w)
r = sum(w)

while l < r:
    m = (l + r) // 2
    stack = car = 0
    for i in w:
        stack += i
        if stack > m:
            stack = i
            car += 1
    if car < k:
        r = m
    else:
        l = m + 1
print(l)