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

def num_luggage(P, K, lst):
    weight = 0
    n_track = 1
    for i, e in enumerate(lst):
        if (e > P):
            return i
        if (weight + e <= P):
            weight += e
        else:
            n_track += 1
            weight = e
        if (n_track == K+1):
            return i
    return len(lst)

left, right = 0, 10000 * N
i_break = 0
while right - left > 1:
    mid = (left+right)//2
    if N <= num_luggage(mid, K, lst):
        right = mid  # ギリギリOKなのはrightに最終的に格納されているはず
    else:  # 余裕がなければ(n>n_nimotu_if_P())、Pを増やす
        left = mid

print(right) 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 lst = [int(input()) for i in range(N)] lst [int(input()) for i in range(N)] def num_luggage(P, K, lst):
    weight = 0
    n_track = 1
    for i, e in enumerate(lst):
        if (e > P):
            return i
        if (weight + e <= P):
            weight += e
        else:
            n_track += 1
            weight = e
        if (n_track == K+1):
            return i
    return len(lst) num_luggage weight = 0 weight 0 n_track = 1 n_track 1 for i, e in enumerate(lst):
        if (e > P):
            return i
        if (weight + e <= P):
            weight += e
        else:
            n_track += 1
            weight = e
        if (n_track == K+1):
            return i
     i e enumerate(lst) enumerate lst if (e > P):
            return i
         e > P e P return i i if (weight + e <= P):
            weight += e
        else:
            n_track += 1
            weight = e
         weight + e <= P weight + e weight e P weight += e weight e n_track += 1 n_track 1 weight = e weight e if (n_track == K+1):
            return i
     n_track == K+1 n_track K+1 K 1 return i i return len(lst) len(lst) len lst P P K K lst lst left, right = 0, 10000 * N left 0 right 10000 * N 10000 N i_break = 0 i_break 0 while right - left > 1:
    mid = (left+right)//2
    if N <= num_luggage(mid, K, lst):
        right = mid  # ギリギリOKなのはrightに最終的に格納されているはず
    else:  # 余裕がなければ(n>n_nimotu_if_P())、Pを増やす
        left = mid right - left > 1 right - left right left 1 mid = (left+right)//2 mid (left+right)//2 left+right left right 2 if N <= num_luggage(mid, K, lst):
        right = mid  # ギリギリOKなのはrightに最終的に格納されているはず
    else:  # 余裕がなければ(n>n_nimotu_if_P())、Pを増やす
        left = mid N <= num_luggage(mid, K, lst) N num_luggage(mid, K, lst) num_luggage mid K lst right = mid right mid left = mid left mid print(right) print right left = mid mid left left, right = 0, 10000 * N 0 left K = map(int, input().split()) map(int, input().split()) K lst = [int(input()) for i in range(N)] [int(input()) for i in range(N)] lst i_break = 0 0 i_break right = mid mid right def num_luggage(P, K, lst):
    weight = 0
    n_track = 1
    for i, e in enumerate(lst):
        if (e > P):
            return i
        if (weight + e <= P):
            weight += e
        else:
            n_track += 1
            weight = e
        if (n_track == K+1):
            return i
    return len(lst) def num_luggage(P, K, lst):
    weight = 0
    n_track = 1
    for i, e in enumerate(lst):
        if (e > P):
            return i
        if (weight + e <= P):
            weight += e
        else:
            n_track += 1
            weight = e
        if (n_track == K+1):
            return i
    return len(lst) num_luggage mid = (left+right)//2 (left+right)//2 mid N, K = map(int, input().split()) map(int, input().split()) N right = 0, 10000 * N 10000 * N right
N, K = map(int, input().split())
lst = [int(input()) for i in range(N)]

def num_luggage(P, K, lst):
    weight = 0
    n_track = 1
    for i, e in enumerate(lst):
        if (e > P):
            return i
        if (weight + e <= P):
            weight += e
        else:
            n_track += 1
            weight = e
        if (n_track == K+1):
            return i
    return len(lst)

left, right = 0, 10000 * N
i_break = 0
while right - left > 1:
    mid = (left+right)//2
    if N <= num_luggage(mid, K, lst):
        right = mid  # ギリギリOKなのはrightに最終的に格納されているはず
    else:  # 余裕がなければ(n>n_nimotu_if_P())、Pを増やす
        left = mid

print(right)
