N, K = [int(s) for s in raw_input().split()]
ws = [int(raw_input()) for _ in xrange(N)]
lo, hi = max(ws) - 1, sum(ws)

while hi - lo > 1:
    p = P = (lo + hi) / 2
    k = 1
    for w in ws:
        if w > p:
            p = P
            k += 1
        p -= w
    if k <= K:
        hi = P
    else:
        lo = P

print hi int(s) for s in raw_input().split() for s in raw_input().split() s raw_input().split() ().split () raw_input split for s in raw_input().split() int(s) int s N, K = [int(s) for s in raw_input().split()] N [int(s) for s in raw_input().split()] K int(raw_input()) for _ in xrange(N) for _ in xrange(N) _ xrange(N) xrange N for _ in xrange(N) int(raw_input()) int raw_input() raw_input ws = [int(raw_input()) for _ in xrange(N)] ws [int(raw_input()) for _ in xrange(N)] lo, hi = max(ws) - 1, sum(ws) lo max(ws) - 1 max(ws) max ws 1 hi sum(ws) sum ws while hi - lo > 1:
    p = P = (lo + hi) / 2
    k = 1
    for w in ws:
        if w > p:
            p = P
            k += 1
        p -= w
    if k <= 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 k = 1 k 1 for w in ws:
        if w > p:
            p = P
            k += 1
        p -= w
     w ws if w > p:
            p = P
            k += 1
         w > p w p p = P p P k += 1 k 1 p -= w p w if k <= K:
        hi = P
    else:
        lo = P k <= K k K hi = P hi P lo = P lo P print hi = max(ws) - 1, sum(ws) sum(ws) hi lo, hi = max(ws) - 1, sum(ws) max(ws) - 1 lo p = P = (lo + hi) / 2 (lo + hi) / 2 p k = 1 1 k ws = [int(raw_input()) for _ in xrange(N)] [int(raw_input()) for _ in xrange(N)] ws hi = P P hi k += 1 1 k p = P P p N, K = [int(s) for s in raw_input().split()] [int(s) for s in raw_input().split()] N K = [int(s) for s in raw_input().split()] [int(s) for s in raw_input().split()] K p -= w w p lo = P P lo P = (lo + hi) / 2 (lo + hi) / 2 P
N, K = [int(s) for s in raw_input().split()]
ws = [int(raw_input()) for _ in xrange(N)]
lo, hi = max(ws) - 1, sum(ws)

while hi - lo > 1:
    p = P = (lo + hi) / 2
    k = 1
    for w in ws:
        if w > p:
            p = P
            k += 1
        p -= w
    if k <= K:
        hi = P
    else:
        lo = P

print hi