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

def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n:
                return True
    return False

ng, ok = 0, 10**9
while ok-ng > 1:
    mid = (ng+ok)//2
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok) 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):
    i = 0
    for _ in range(k):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n:
                return True
    return False check i = 0 i 0 for _ in range(k):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n:
                return True
     _ range(k) range k s = 0 s 0 while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n:
                return True
     s + w[i] <= p s + w[i] s w[i] w i p s += w[i] s w[i] w i i += 1 i 1 if i == n:
                return True
     i == n i n return True True return False False p p ng, ok = 0, 10**9 ng 0 ok 10**9 10 9 while ok-ng > 1:
    mid = (ng+ok)//2
    if check(mid):
        ok = mid
    else:
        ng = mid ok-ng > 1 ok-ng ok ng 1 mid = (ng+ok)//2 mid (ng+ok)//2 ng+ok ng ok 2 if check(mid):
        ok = mid
    else:
        ng = mid check(mid) check mid ok = mid ok mid ng = mid ng mid print(ok) print ok ok = 0, 10**9 10**9 ok def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n:
                return True
    return False def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n:
                return True
    return False check k = map(int, input().split()) map(int, input().split()) k mid = (ng+ok)//2 (ng+ok)//2 mid ok = mid mid ok ng = mid mid ng n, k = map(int, input().split()) map(int, input().split()) n w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w ng, ok = 0, 10**9 0 ng
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(p):
    i = 0
    for _ in range(k):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n:
                return True
    return False

ng, ok = 0, 10**9
while ok-ng > 1:
    mid = (ng+ok)//2
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok)
