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

def check(p):
    """
    :param p: 最大積載量
    :return: 積むことができる荷物の数
    """
    global k # トラックの台数
    global t # 荷物の重さのリスト
    i = 0
    for _ in range(k):
        remaining = p
        while remaining >= t[i]:
            remaining -= t[i]
            i += 1
            if  i == len(t):
                return i
    return i

lo = 0
hi = 10**6 * 10**4

p = 0

while hi - lo > 1:
    mid = (lo + hi) // 2
    if check(mid) < n:
        lo = mid
    else:
        hi = mid
ans = hi
print(ans) n,k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k 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 t = [int(input()) for i in range(n)] t [int(input()) for i in range(n)] def check(p):
    """
    :param p: 最大積載量
    :return: 積むことができる荷物の数
    """
    global k # トラックの台数
    global t # 荷物の重さのリスト
    i = 0
    for _ in range(k):
        remaining = p
        while remaining >= t[i]:
            remaining -= t[i]
            i += 1
            if  i == len(t):
                return i
    return i check """
    :param p: 最大積載量
    :return: 積むことができる荷物の数
    """ global k global t i = 0 i 0 for _ in range(k):
        remaining = p
        while remaining >= t[i]:
            remaining -= t[i]
            i += 1
            if  i == len(t):
                return i
     _ range(k) range k remaining = p remaining p while remaining >= t[i]:
            remaining -= t[i]
            i += 1
            if  i == len(t):
                return i
     remaining >= t[i] remaining t[i] t i remaining -= t[i] remaining t[i] t i i += 1 i 1 if  i == len(t):
                return i
     i == len(t) i len(t) len t return i i return i i p p lo = 0 lo 0 hi = 10**6 * 10**4 hi 10**6 * 10**4 10**6 10 6 10**4 10 4 p = 0 p 0 while hi - lo > 1:
    mid = (lo + hi) // 2
    if check(mid) < n:
        lo = mid
    else:
        hi = mid hi - lo > 1 hi - lo hi lo 1 mid = (lo + hi) // 2 mid (lo + hi) // 2 lo + hi lo hi 2 if check(mid) < n:
        lo = mid
    else:
        hi = mid check(mid) < n check(mid) check mid n lo = mid lo mid hi = mid hi mid ans = hi ans hi print(ans) print ans n,k = map(int, input().split()) map(int, input().split()) n def check(p):
    """
    :param p: 最大積載量
    :return: 積むことができる荷物の数
    """
    global k # トラックの台数
    global t # 荷物の重さのリスト
    i = 0
    for _ in range(k):
        remaining = p
        while remaining >= t[i]:
            remaining -= t[i]
            i += 1
            if  i == len(t):
                return i
    return i def check(p):
    """
    :param p: 最大積載量
    :return: 積むことができる荷物の数
    """
    global k # トラックの台数
    global t # 荷物の重さのリスト
    i = 0
    for _ in range(k):
        remaining = p
        while remaining >= t[i]:
            remaining -= t[i]
            i += 1
            if  i == len(t):
                return i
    return i check p = 0 0 p hi = mid mid hi k = map(int, input().split()) map(int, input().split()) k hi = 10**6 * 10**4 10**6 * 10**4 hi mid = (lo + hi) // 2 (lo + hi) // 2 mid lo = 0 0 lo t = [int(input()) for i in range(n)] [int(input()) for i in range(n)] t ans = hi hi ans lo = mid mid lo
n,k = map(int, input().split())
t = [int(input()) for i in range(n)]

def check(p):
    """
    :param p: 最大積載量
    :return: 積むことができる荷物の数
    """
    global k # トラックの台数
    global t # 荷物の重さのリスト
    i = 0
    for _ in range(k):
        remaining = p
        while remaining >= t[i]:
            remaining -= t[i]
            i += 1
            if  i == len(t):
                return i
    return i

lo = 0
hi = 10**6 * 10**4

p = 0

while hi - lo > 1:
    mid = (lo + hi) // 2
    if check(mid) < n:
        lo = mid
    else:
        hi = mid
ans = hi
print(ans)
