import sys
readline = sys.stdin.readline
n, k = map(int, input().split())
v = [int(readline()) for _ in range(n)]
lo = max(v) - 1
hi = int(1e10)
while hi - lo > 1:
    p = P = (lo + hi) // 2
    m = 1
    for i in range(n):
        if v[i] > p:
            p = P
            m += 1
        p -= v[i]
    if m <= k:
        hi = P
    else:
        lo = P
print(hi)
 import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(readline()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(readline()) int readline() readline v = [int(readline()) for _ in range(n)] v [int(readline()) for _ in range(n)] lo = max(v) - 1 lo max(v) - 1 max(v) max v 1 hi = int(1e10) hi int(1e10) int 1e10 while hi - lo > 1:
    p = P = (lo + hi) // 2
    m = 1
    for i in range(n):
        if v[i] > p:
            p = P
            m += 1
        p -= v[i]
    if m <= k:
        hi = P
    else:
        lo = P hi - lo > 1 hi - lo hi lo 1 p = P = (lo + hi) // 2 p (lo + hi) // 2 lo + hi lo hi 2 = P = (lo + hi) // 2 P (lo + hi) // 2 m = 1 m 1 for i in range(n):
        if v[i] > p:
            p = P
            m += 1
        p -= v[i]
     i range(n) range n if v[i] > p:
            p = P
            m += 1
         v[i] > p v[i] v i p p = P p P m += 1 m 1 p -= v[i] p v[i] v i if m <= k:
        hi = P
    else:
        lo = P m <= k m k hi = P hi P lo = P lo P print(hi) print hi k = map(int, input().split()) map(int, input().split()) k v = [int(readline()) for _ in range(n)] [int(readline()) for _ in range(n)] v hi = int(1e10) int(1e10) hi p -= v[i] v[i] p readline = sys.stdin.readline sys.stdin.readline readline n, k = map(int, input().split()) map(int, input().split()) n hi = P P hi lo = max(v) - 1 max(v) - 1 lo p = P = (lo + hi) // 2 (lo + hi) // 2 p p = P P p P = (lo + hi) // 2 (lo + hi) // 2 P m = 1 1 m lo = P P lo m += 1 1 m
import sys
readline = sys.stdin.readline
n, k = map(int, input().split())
v = [int(readline()) for _ in range(n)]
lo = max(v) - 1
hi = int(1e10)
while hi - lo > 1:
    p = P = (lo + hi) // 2
    m = 1
    for i in range(n):
        if v[i] > p:
            p = P
            m += 1
        p -= v[i]
    if m <= k:
        hi = P
    else:
        lo = P
print(hi)

