import sys

N, K = [int(s) for s in raw_input().split()]
ws = [int(raw_input()) for _ in xrange(N)]
lo, hi = max(ws), 100000 * 10000

while lo != hi:
    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 + 1

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

N, K = [int(s) for s in raw_input().split()]
ws = [int(raw_input()) for _ in xrange(N)]
lo, hi = max(ws), 100000 * 10000

while lo != hi:
    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 + 1

print lo