def check(list, p, k):
    i = 0
    for j in range(k):
        sum = 0
        while sum+list[i] <= p:
            sum += list[i]
            i += 1
            if i == len(list):
                return i


    return i

nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]

list = []
for i in range(n):
    list.append(int(input()))

max_num = 100000 * 10000

#二分探索で最大積載量の最小値を求める
left = 0
right = max_num
while left+1 < right:
    mid = int((left + right) /2)
    if check(list, mid, k) >= len(list):
        right = mid
    else:
        left = mid

print(right)
 def check(list, p, k):
    i = 0
    for j in range(k):
        sum = 0
        while sum+list[i] <= p:
            sum += list[i]
            i += 1
            if i == len(list):
                return i


    return i check i = 0 i 0 for j in range(k):
        sum = 0
        while sum+list[i] <= p:
            sum += list[i]
            i += 1
            if i == len(list):
                return i


     j range(k) range k sum = 0 sum 0 while sum+list[i] <= p:
            sum += list[i]
            i += 1
            if i == len(list):
                return i


     sum+list[i] <= p sum+list[i] sum list[i] list i p sum += list[i] sum list[i] list i i += 1 i 1 if i == len(list):
                return i


     i == len(list) i len(list) len list return i i return i i list list p p k k nk = list(map(int, input().split())) nk list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split n = nk[0] n nk[0] nk 0 k = nk[1] k nk[1] nk 1 list = [] list [] for i in range(n):
    list.append(int(input())) i range(n) range n list.append(int(input())) list.append list append int(input()) int input() input max_num = 100000 * 10000 max_num 100000 * 10000 100000 10000 left = 0 left 0 right = max_num right max_num while left+1 < right:
    mid = int((left + right) /2)
    if check(list, mid, k) >= len(list):
        right = mid
    else:
        left = mid left+1 < right left+1 left 1 right mid = int((left + right) /2) mid int((left + right) /2) int (left + right) /2 left + right left right 2 if check(list, mid, k) >= len(list):
        right = mid
    else:
        left = mid check(list, mid, k) >= len(list) check(list, mid, k) check list mid k len(list) len list right = mid right mid left = mid left mid print(right) print right list = [] [] list right = max_num max_num right left = mid mid left nk = list(map(int, input().split())) list(map(int, input().split())) nk k = nk[1] nk[1] k mid = int((left + right) /2) int((left + right) /2) mid def check(list, p, k):
    i = 0
    for j in range(k):
        sum = 0
        while sum+list[i] <= p:
            sum += list[i]
            i += 1
            if i == len(list):
                return i


    return i def check(list, p, k):
    i = 0
    for j in range(k):
        sum = 0
        while sum+list[i] <= p:
            sum += list[i]
            i += 1
            if i == len(list):
                return i


    return i check n = nk[0] nk[0] n max_num = 100000 * 10000 100000 * 10000 max_num left = 0 0 left right = mid mid right
def check(list, p, k):
    i = 0
    for j in range(k):
        sum = 0
        while sum+list[i] <= p:
            sum += list[i]
            i += 1
            if i == len(list):
                return i


    return i

nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]

list = []
for i in range(n):
    list.append(int(input()))

max_num = 100000 * 10000

#二分探索で最大積載量の最小値を求める
left = 0
right = max_num
while left+1 < right:
    mid = int((left + right) /2)
    if check(list, mid, k) >= len(list):
        right = mid
    else:
        left = mid

print(right)

