import math

n,k = (int(x) for x in input().split())
w = list()

for i in range(0, n):
    w.append(int(input()))

def check(P):
    i = 0
    for j in range(0, k):
        summ = 0
        while(summ + w[i] <= P):
            summ += w[i]
            i += 1
            if(i == n): #最後までしまえたら終了
                return n

    return i #入りきらなかったら終了

def Binary_Search():
    left = 0
    right = 100000*100000
    while(right - left > 1):
        mid = math.floor((left + right) / 2)
        if(check(mid) >= n): #全部トラックに入ったなら範囲の最大値をを狭める
            right = mid
        else:
            left = mid

    return right

ans = Binary_Search()

print(ans)
 import math math int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x n,k = (int(x) for x in input().split()) n (int(x) for x in input().split()) k w = list() w list() list for i in range(0, n):
    w.append(int(input())) i range(0, n) range 0 n w.append(int(input())) w.append w append int(input()) int input() input def check(P):
    i = 0
    for j in range(0, k):
        summ = 0
        while(summ + w[i] <= P):
            summ += w[i]
            i += 1
            if(i == n): #最後までしまえたら終了
                return n

    return i #入りきらなかったら終了 check i = 0 i 0 for j in range(0, k):
        summ = 0
        while(summ + w[i] <= P):
            summ += w[i]
            i += 1
            if(i == n): #最後までしまえたら終了
                return n

     j range(0, k) range 0 k summ = 0 summ 0 while(summ + w[i] <= P):
            summ += w[i]
            i += 1
            if(i == n): #最後までしまえたら終了
                return n

     summ + w[i] <= P summ + w[i] summ w[i] w i P summ += w[i] summ w[i] w i i += 1 i 1 if(i == n): #最後までしまえたら終了
                return n

     i == n i n return n n return i i P P def Binary_Search():
    left = 0
    right = 100000*100000
    while(right - left > 1):
        mid = math.floor((left + right) / 2)
        if(check(mid) >= n): #全部トラックに入ったなら範囲の最大値をを狭める
            right = mid
        else:
            left = mid

    return right Binary_Search left = 0 left 0 right = 100000*100000 right 100000*100000 100000 100000 while(right - left > 1):
        mid = math.floor((left + right) / 2)
        if(check(mid) >= n): #全部トラックに入ったなら範囲の最大値をを狭める
            right = mid
        else:
            left = mid

     right - left > 1 right - left right left 1 mid = math.floor((left + right) / 2) mid math.floor((left + right) / 2) math.floor math floor (left + right) / 2 left + right left right 2 if(check(mid) >= n): #全部トラックに入ったなら範囲の最大値をを狭める
            right = mid
        else:
            left = mid

     check(mid) >= n check(mid) check mid n right = mid right mid left = mid left mid return right right ans = Binary_Search() ans Binary_Search() Binary_Search print(ans) print ans def check(P):
    i = 0
    for j in range(0, k):
        summ = 0
        while(summ + w[i] <= P):
            summ += w[i]
            i += 1
            if(i == n): #最後までしまえたら終了
                return n

    return i #入りきらなかったら終了 def check(P):
    i = 0
    for j in range(0, k):
        summ = 0
        while(summ + w[i] <= P):
            summ += w[i]
            i += 1
            if(i == n): #最後までしまえたら終了
                return n

    return i #入りきらなかったら終了 check def Binary_Search():
    left = 0
    right = 100000*100000
    while(right - left > 1):
        mid = math.floor((left + right) / 2)
        if(check(mid) >= n): #全部トラックに入ったなら範囲の最大値をを狭める
            right = mid
        else:
            left = mid

    return right def Binary_Search():
    left = 0
    right = 100000*100000
    while(right - left > 1):
        mid = math.floor((left + right) / 2)
        if(check(mid) >= n): #全部トラックに入ったなら範囲の最大値をを狭める
            right = mid
        else:
            left = mid

    return right Binary_Search k = (int(x) for x in input().split()) (int(x) for x in input().split()) k n,k = (int(x) for x in input().split()) (int(x) for x in input().split()) n w = list() list() w ans = Binary_Search() Binary_Search() ans
import math

n,k = (int(x) for x in input().split())
w = list()

for i in range(0, n):
    w.append(int(input()))

def check(P):
    i = 0
    for j in range(0, k):
        summ = 0
        while(summ + w[i] <= P):
            summ += w[i]
            i += 1
            if(i == n): #最後までしまえたら終了
                return n

    return i #入りきらなかったら終了

def Binary_Search():
    left = 0
    right = 100000*100000
    while(right - left > 1):
        mid = math.floor((left + right) / 2)
        if(check(mid) >= n): #全部トラックに入ったなら範囲の最大値をを狭める
            right = mid
        else:
            left = mid

    return right

ans = Binary_Search()

print(ans)

