n, k = (int(x) for x in input().split())

w = []
w = [int(input()) for i in range(n)]

def f(x):
    count = 0
    for i in range(k):
        s = 0
        while s + w[count] <= x:
            s += w[count]
            count += 1
            if count == n:
                return n
    return count

left = 0
right = 100000 * 100000

while right - left > 1:
    mid = (left + right) // 2
    v = f(mid)
    if v >= n:
        right = mid
    else:
        left = mid

print(right) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x n, k = (int(x) for x in input().split()) n (int(x) for x in input().split()) k w = [] w [] int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input w = [int(input()) for i in range(n)] w [int(input()) for i in range(n)] def f(x):
    count = 0
    for i in range(k):
        s = 0
        while s + w[count] <= x:
            s += w[count]
            count += 1
            if count == n:
                return n
    return count f count = 0 count 0 for i in range(k):
        s = 0
        while s + w[count] <= x:
            s += w[count]
            count += 1
            if count == n:
                return n
     i range(k) range k s = 0 s 0 while s + w[count] <= x:
            s += w[count]
            count += 1
            if count == n:
                return n
     s + w[count] <= x s + w[count] s w[count] w count x s += w[count] s w[count] w count count += 1 count 1 if count == n:
                return n
     count == n count n return n n return count count x x left = 0 left 0 right = 100000 * 100000 right 100000 * 100000 100000 100000 while right - left > 1:
    mid = (left + right) // 2
    v = f(mid)
    if v >= n:
        right = mid
    else:
        left = mid right - left > 1 right - left right left 1 mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 v = f(mid) v f(mid) f mid if v >= n:
        right = mid
    else:
        left = mid v >= n v n right = mid right mid left = mid left mid print(right) print right left = mid mid left k = (int(x) for x in input().split()) (int(x) for x in input().split()) k w = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w right = 100000 * 100000 100000 * 100000 right v = f(mid) f(mid) v def f(x):
    count = 0
    for i in range(k):
        s = 0
        while s + w[count] <= x:
            s += w[count]
            count += 1
            if count == n:
                return n
    return count def f(x):
    count = 0
    for i in range(k):
        s = 0
        while s + w[count] <= x:
            s += w[count]
            count += 1
            if count == n:
                return n
    return count f n, k = (int(x) for x in input().split()) (int(x) for x in input().split()) n w = [] [] w mid = (left + right) // 2 (left + right) // 2 mid right = mid mid right left = 0 0 left
n, k = (int(x) for x in input().split())

w = []
w = [int(input()) for i in range(n)]

def f(x):
    count = 0
    for i in range(k):
        s = 0
        while s + w[count] <= x:
            s += w[count]
            count += 1
            if count == n:
                return n
    return count

left = 0
right = 100000 * 100000

while right - left > 1:
    mid = (left + right) // 2
    v = f(mid)
    if v >= n:
        right = mid
    else:
        left = mid

print(right)
