n, _k = map(int, raw_input().split())
w = [int(raw_input()) for i in xrange(n)]

l, r = max(w), sum(w)
while r > l:
    P = (r + l) / 2
    c = P
    k = _k - 1
    for wi in w:
        if c >= wi: c -= wi
        else:
            c = P - wi
            k -= 1
            if k < 0:
                break
    if k >= 0:
        r = P
    else:
        l = P + 1
print l n, _k = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split _k int(raw_input()) for i in xrange(n) for i in xrange(n) i xrange(n) xrange n for i in xrange(n) int(raw_input()) int raw_input() raw_input w = [int(raw_input()) for i in xrange(n)] w [int(raw_input()) for i in xrange(n)] l, r = max(w), sum(w) l max(w) max w r sum(w) sum w while r > l:
    P = (r + l) / 2
    c = P
    k = _k - 1
    for wi in w:
        if c >= wi: c -= wi
        else:
            c = P - wi
            k -= 1
            if k < 0:
                break
    if k >= 0:
        r = P
    else:
        l = P + 1 r > l r l P = (r + l) / 2 P (r + l) / 2 r + l r l 2 c = P c P k = _k - 1 k _k - 1 _k 1 for wi in w:
        if c >= wi: c -= wi
        else:
            c = P - wi
            k -= 1
            if k < 0:
                break
     wi w if c >= wi: c -= wi
        else:
            c = P - wi
            k -= 1
            if k < 0:
                break
     c >= wi c wi c = P - wi c P - wi P wi k -= 1 k 1 if k < 0:
                break
     k < 0 k 0 break if k >= 0:
        r = P
    else:
        l = P + 1 k >= 0 k 0 r = P r P l = P + 1 l P + 1 P 1 print n, _k = map(int, raw_input().split()) map(int, raw_input().split()) n P = (r + l) / 2 (r + l) / 2 P _k = map(int, raw_input().split()) map(int, raw_input().split()) _k c = P - wi P - wi c l, r = max(w), sum(w) max(w) l r = P P r r = max(w), sum(w) sum(w) r k -= 1 1 k l = P + 1 P + 1 l c = P P c w = [int(raw_input()) for i in xrange(n)] [int(raw_input()) for i in xrange(n)] w k = _k - 1 _k - 1 k
n, _k = map(int, raw_input().split())
w = [int(raw_input()) for i in xrange(n)]

l, r = max(w), sum(w)
while r > l:
    P = (r + l) / 2
    c = P
    k = _k - 1
    for wi in w:
        if c >= wi: c -= wi
        else:
            c = P - wi
            k -= 1
            if k < 0:
                break
    if k >= 0:
        r = P
    else:
        l = P + 1
print l