n,k = map(int, input().split())
lag = []
for l in range(n):
    lag.append(int(input()))
w_max = 100000*100000
w_min = 0
while w_min < w_max:
    w_mid = (w_max + w_min) // 2
    tracks = 0
    current = 0
    for i in range(n):
        if lag[i] > w_mid:
            tracks = k
            break
        elif lag[i] + current > w_mid:
            tracks += 1
            current = lag[i]
        else:
            current += lag[i]
    if tracks < k:
        w_max = w_mid
    else:
        w_min = w_mid + 1
print(w_max) n,k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k lag = [] lag [] for l in range(n):
    lag.append(int(input())) l range(n) range n lag.append(int(input())) lag.append lag append int(input()) int input() input w_max = 100000*100000 w_max 100000*100000 100000 100000 w_min = 0 w_min 0 while w_min < w_max:
    w_mid = (w_max + w_min) // 2
    tracks = 0
    current = 0
    for i in range(n):
        if lag[i] > w_mid:
            tracks = k
            break
        elif lag[i] + current > w_mid:
            tracks += 1
            current = lag[i]
        else:
            current += lag[i]
    if tracks < k:
        w_max = w_mid
    else:
        w_min = w_mid + 1 w_min < w_max w_min w_max w_mid = (w_max + w_min) // 2 w_mid (w_max + w_min) // 2 w_max + w_min w_max w_min 2 tracks = 0 tracks 0 current = 0 current 0 for i in range(n):
        if lag[i] > w_mid:
            tracks = k
            break
        elif lag[i] + current > w_mid:
            tracks += 1
            current = lag[i]
        else:
            current += lag[i]
     i range(n) range n if lag[i] > w_mid:
            tracks = k
            break
        elif lag[i] + current > w_mid:
            tracks += 1
            current = lag[i]
        else:
            current += lag[i]
     lag[i] > w_mid lag[i] lag i w_mid tracks = k tracks k break elif lag[i] + current > w_mid:
            tracks += 1
            current = lag[i]
         lag[i] + current > w_mid lag[i] + current lag[i] lag i current w_mid tracks += 1 tracks 1 current = lag[i] current lag[i] lag i current += lag[i] current lag[i] lag i if tracks < k:
        w_max = w_mid
    else:
        w_min = w_mid + 1 tracks < k tracks k w_max = w_mid w_max w_mid w_min = w_mid + 1 w_min w_mid + 1 w_mid 1 print(w_max) print w_max current += lag[i] lag[i] current tracks = 0 0 tracks w_max = w_mid w_mid w_max tracks += 1 1 tracks k = map(int, input().split()) map(int, input().split()) k current = 0 0 current w_min = w_mid + 1 w_mid + 1 w_min w_mid = (w_max + w_min) // 2 (w_max + w_min) // 2 w_mid current = lag[i] lag[i] current n,k = map(int, input().split()) map(int, input().split()) n lag = [] [] lag w_max = 100000*100000 100000*100000 w_max w_min = 0 0 w_min tracks = k k tracks
n,k = map(int, input().split())
lag = []
for l in range(n):
    lag.append(int(input()))
w_max = 100000*100000
w_min = 0
while w_min < w_max:
    w_mid = (w_max + w_min) // 2
    tracks = 0
    current = 0
    for i in range(n):
        if lag[i] > w_mid:
            tracks = k
            break
        elif lag[i] + current > w_mid:
            tracks += 1
            current = lag[i]
        else:
            current += lag[i]
    if tracks < k:
        w_max = w_mid
    else:
        w_min = w_mid + 1
print(w_max)