n,k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True

s = max(w)
l = sum(w)
while s < l:
    m = (s+l)//2
    if check(m):
        l = m
    else:
        s = m+1
print(s) n,k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input w = [int(input()) for _ in range(n)] w [int(input()) for _ in range(n)] def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True check c = t = 0 c 0 = t = 0 t 0 for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
     wi w t += wi t wi if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
     t > p t p t = wi t wi c += 1 c 1 if c >= k:
                return False
     c >= k c k return False False return True True p p s = max(w) s max(w) max w l = sum(w) l sum(w) sum w while s < l:
    m = (s+l)//2
    if check(m):
        l = m
    else:
        s = m+1 s < l s l m = (s+l)//2 m (s+l)//2 s+l s l 2 if check(m):
        l = m
    else:
        s = m+1 check(m) check m l = m l m s = m+1 s m+1 m 1 print(s) print s l = m m l l = sum(w) sum(w) l w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w m = (s+l)//2 (s+l)//2 m k = map(int, input().split()) map(int, input().split()) k def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True check s = m+1 m+1 s n,k = map(int, input().split()) map(int, input().split()) n s = max(w) max(w) s
n,k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True

s = max(w)
l = sum(w)
while s < l:
    m = (s+l)//2
    if check(m):
        l = m
    else:
        s = m+1
print(s)