#インプットdataの格納
n, k = map(int, input().split())
n_list = list()
for i in range(n):
    n_list.append(int(input()))

#data処理
left = 0
right = 100000*10000
while (right - left) > 1:
    mid = (left + right) // 2

    i = 0
    for j in range(k):
        weight = 0
        while i < n:
            if (weight + n_list[i]) > mid:
                break
            else:
                weight += n_list[i]
                i += 1

    if i >= n:
        right = mid
    else:
        left = mid
        
#結果表示
print(right)
 n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k n_list = list() n_list list() list for i in range(n):
    n_list.append(int(input()))

#data処理 i range(n) range n n_list.append(int(input())) n_list.append n_list append int(input()) int input() input left = 0 left 0 right = 100000*10000 right 100000*10000 100000 10000 while (right - left) > 1:
    mid = (left + right) // 2

    i = 0
    for j in range(k):
        weight = 0
        while i < n:
            if (weight + n_list[i]) > mid:
                break
            else:
                weight += n_list[i]
                i += 1

    if i >= n:
        right = mid
    else:
        left = mid
        
#結果表示 (right - left) > 1 right - left right left 1 mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 i = 0 i 0 for j in range(k):
        weight = 0
        while i < n:
            if (weight + n_list[i]) > mid:
                break
            else:
                weight += n_list[i]
                i += 1

     j range(k) range k weight = 0 weight 0 while i < n:
            if (weight + n_list[i]) > mid:
                break
            else:
                weight += n_list[i]
                i += 1

     i < n i n if (weight + n_list[i]) > mid:
                break
            else:
                weight += n_list[i]
                i += 1

     (weight + n_list[i]) > mid weight + n_list[i] weight n_list[i] n_list i mid break weight += n_list[i] weight n_list[i] n_list i i += 1 i 1 if i >= n:
        right = mid
    else:
        left = mid
        
#結果表示 i >= n i n right = mid right mid left = mid left mid print(right) print right i = 0 0 i i += 1 1 i n, k = map(int, input().split()) map(int, input().split()) n mid = (left + right) // 2 (left + right) // 2 mid k = map(int, input().split()) map(int, input().split()) k weight += n_list[i] n_list[i] weight right = 100000*10000 100000*10000 right right = mid mid right left = 0 0 left weight = 0 0 weight n_list = list() list() n_list left = mid mid left
#インプットdataの格納
n, k = map(int, input().split())
n_list = list()
for i in range(n):
    n_list.append(int(input()))

#data処理
left = 0
right = 100000*10000
while (right - left) > 1:
    mid = (left + right) // 2

    i = 0
    for j in range(k):
        weight = 0
        while i < n:
            if (weight + n_list[i]) > mid:
                break
            else:
                weight += n_list[i]
                i += 1

    if i >= n:
        right = mid
    else:
        left = mid
        
#結果表示
print(right)

