N, K = map(int, input().split())
W = []

for i in range(N):
    W.append(int(input()))

def f(N, K, W, p):
    cnt = 0
    k = 1
    c_k = 0
    for w in W:
        if c_k + w <= p:
            c_k = c_k + w
            cnt = cnt + 1
        elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
        elif k < K and w > p:
            pass
        else:
            break
    return cnt

start = 0
end = 1000000000
while start != end:
    center = (start + end)//2
    if f(N, K, W, center) < N:
        start = center + 1
    else:
        end = center

print(start) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K W = [] W [] for i in range(N):
    W.append(int(input())) i range(N) range N W.append(int(input())) W.append W append int(input()) int input() input def f(N, K, W, p):
    cnt = 0
    k = 1
    c_k = 0
    for w in W:
        if c_k + w <= p:
            c_k = c_k + w
            cnt = cnt + 1
        elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
        elif k < K and w > p:
            pass
        else:
            break
    return cnt f cnt = 0 cnt 0 k = 1 k 1 c_k = 0 c_k 0 for w in W:
        if c_k + w <= p:
            c_k = c_k + w
            cnt = cnt + 1
        elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
        elif k < K and w > p:
            pass
        else:
            break
     w W if c_k + w <= p:
            c_k = c_k + w
            cnt = cnt + 1
        elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
        elif k < K and w > p:
            pass
        else:
            break
     c_k + w <= p c_k + w c_k w p c_k = c_k + w c_k c_k + w c_k w cnt = cnt + 1 cnt cnt + 1 cnt 1 elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
         k < K and w <= p k < K k K w <= p w p k = k + 1 k k + 1 k 1 c_k = w c_k w cnt = cnt + 1 cnt cnt + 1 cnt 1 elif k < K and w > p:
            pass
         k < K and w > p k < K k K w > p w p break return cnt cnt N N K K W W p p start = 0 start 0 end = 1000000000 end 1000000000 while start != end:
    center = (start + end)//2
    if f(N, K, W, center) < N:
        start = center + 1
    else:
        end = center start != end start end center = (start + end)//2 center (start + end)//2 start + end start end 2 if f(N, K, W, center) < N:
        start = center + 1
    else:
        end = center f(N, K, W, center) < N f(N, K, W, center) f N K W center N start = center + 1 start center + 1 center 1 end = center end center print(start) print start N, K = map(int, input().split()) map(int, input().split()) N end = 1000000000 1000000000 end K = map(int, input().split()) map(int, input().split()) K W = [] [] W center = (start + end)//2 (start + end)//2 center def f(N, K, W, p):
    cnt = 0
    k = 1
    c_k = 0
    for w in W:
        if c_k + w <= p:
            c_k = c_k + w
            cnt = cnt + 1
        elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
        elif k < K and w > p:
            pass
        else:
            break
    return cnt def f(N, K, W, p):
    cnt = 0
    k = 1
    c_k = 0
    for w in W:
        if c_k + w <= p:
            c_k = c_k + w
            cnt = cnt + 1
        elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
        elif k < K and w > p:
            pass
        else:
            break
    return cnt f start = 0 0 start end = center center end start = center + 1 center + 1 start
N, K = map(int, input().split())
W = []

for i in range(N):
    W.append(int(input()))

def f(N, K, W, p):
    cnt = 0
    k = 1
    c_k = 0
    for w in W:
        if c_k + w <= p:
            c_k = c_k + w
            cnt = cnt + 1
        elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
        elif k < K and w > p:
            pass
        else:
            break
    return cnt

start = 0
end = 1000000000
while start != end:
    center = (start + end)//2
    if f(N, K, W, center) < N:
        start = center + 1
    else:
        end = center

print(start)
