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

def f(P):
    tmp_capacity = P
    num_used_truck = 1
    i = 0
    while i <= N-1:
        if w[i] > P:
            return i
        if w[i] > tmp_capacity:
            tmp_capacity = P
            num_used_truck += 1
            if num_used_truck >= K+1:
                return i

        tmp_capacity -= w[i]
        i += 1
    
    return i

left = 0
right = 1e9
mid = right
flag = 0
while right - left > 1:
    mid = (left + right)//2
    tmp = f(mid)
    if tmp >= N:
        right = mid
    elif tmp < N:
        left = mid
print(int(right)) 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 f(P):
    tmp_capacity = P
    num_used_truck = 1
    i = 0
    while i <= N-1:
        if w[i] > P:
            return i
        if w[i] > tmp_capacity:
            tmp_capacity = P
            num_used_truck += 1
            if num_used_truck >= K+1:
                return i

        tmp_capacity -= w[i]
        i += 1
    
    return i f tmp_capacity = P tmp_capacity P num_used_truck = 1 num_used_truck 1 i = 0 i 0 while i <= N-1:
        if w[i] > P:
            return i
        if w[i] > tmp_capacity:
            tmp_capacity = P
            num_used_truck += 1
            if num_used_truck >= K+1:
                return i

        tmp_capacity -= w[i]
        i += 1
    
     i <= N-1 i N-1 N 1 if w[i] > P:
            return i
         w[i] > P w[i] w i P return i i if w[i] > tmp_capacity:
            tmp_capacity = P
            num_used_truck += 1
            if num_used_truck >= K+1:
                return i

         w[i] > tmp_capacity w[i] w i tmp_capacity tmp_capacity = P tmp_capacity P num_used_truck += 1 num_used_truck 1 if num_used_truck >= K+1:
                return i

         num_used_truck >= K+1 num_used_truck K+1 K 1 return i i tmp_capacity -= w[i] tmp_capacity w[i] w i i += 1 i 1 return i i P P left = 0 left 0 right = 1e9 right 1e9 mid = right mid right flag = 0 flag 0 while right - left > 1:
    mid = (left + right)//2
    tmp = f(mid)
    if tmp >= N:
        right = mid
    elif tmp < N:
        left = mid right - left > 1 right - left right left 1 mid = (left + right)//2 mid (left + right)//2 left + right left right 2 tmp = f(mid) tmp f(mid) f mid if tmp >= N:
        right = mid
    elif tmp < N:
        left = mid tmp >= N tmp N right = mid right mid elif tmp < N:
        left = mid tmp < N tmp N left = mid left mid print(int(right)) print int(right) int right K = map(int, input().split()) map(int, input().split()) K left = mid mid left tmp = f(mid) f(mid) tmp flag = 0 0 flag right = mid mid right mid = right right mid mid = (left + right)//2 (left + right)//2 mid left = 0 0 left 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 def f(P):
    tmp_capacity = P
    num_used_truck = 1
    i = 0
    while i <= N-1:
        if w[i] > P:
            return i
        if w[i] > tmp_capacity:
            tmp_capacity = P
            num_used_truck += 1
            if num_used_truck >= K+1:
                return i

        tmp_capacity -= w[i]
        i += 1
    
    return i def f(P):
    tmp_capacity = P
    num_used_truck = 1
    i = 0
    while i <= N-1:
        if w[i] > P:
            return i
        if w[i] > tmp_capacity:
            tmp_capacity = P
            num_used_truck += 1
            if num_used_truck >= K+1:
                return i

        tmp_capacity -= w[i]
        i += 1
    
    return i f right = 1e9 1e9 right
N, K = map(int, input().split())
w = [int(input()) for _ in range(N)]

def f(P):
    tmp_capacity = P
    num_used_truck = 1
    i = 0
    while i <= N-1:
        if w[i] > P:
            return i
        if w[i] > tmp_capacity:
            tmp_capacity = P
            num_used_truck += 1
            if num_used_truck >= K+1:
                return i

        tmp_capacity -= w[i]
        i += 1
    
    return i

left = 0
right = 1e9
mid = right
flag = 0
while right - left > 1:
    mid = (left + right)//2
    tmp = f(mid)
    if tmp >= N:
        right = mid
    elif tmp < N:
        left = mid
print(int(right))
