n, k = map(int, input().split())
l = list(int(input()) for i in range(n))

left = max(l)-1; right = sum(l)

while left+1 < right:  #最大値と合計値の間のどこかに考えるべき値が存在する
    mid = (left + right) // 2
    cnt = 1; cur = 0  #初期化
    for a in l:
        if mid < cur + a:
            cur = a
            cnt += 1
        else:
            cur += a

    if cnt <= k:
        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 l = list(int(input()) for i in range(n)) l list(int(input()) for i in range(n)) list int(input()) int input() input left = max(l)-1 left max(l)-1 max(l) max l 1 right = sum(l) right sum(l) sum l while left+1 < right:  #最大値と合計値の間のどこかに考えるべき値が存在する
    mid = (left + right) // 2
    cnt = 1; cur = 0  #初期化
    for a in l:
        if mid < cur + a:
            cur = a
            cnt += 1
        else:
            cur += a

    if cnt <= k:
        right = mid
    else:
        left = mid left+1 < right left+1 left 1 right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 cnt = 1 cnt 1 cur = 0 cur 0 for a in l:
        if mid < cur + a:
            cur = a
            cnt += 1
        else:
            cur += a

     a l if mid < cur + a:
            cur = a
            cnt += 1
        else:
            cur += a

     mid < cur + a mid cur + a cur a cur = a cur a cnt += 1 cnt 1 cur += a cur a if cnt <= k:
        right = mid
    else:
        left = mid cnt <= k cnt k right = mid right mid left = mid left mid print(right) print right left = max(l)-1 max(l)-1 left cnt += 1 1 cnt cur = a a cur cur += a a cur n, k = map(int, input().split()) map(int, input().split()) n mid = (left + right) // 2 (left + right) // 2 mid cnt = 1 1 cnt left = mid mid left l = list(int(input()) for i in range(n)) list(int(input()) for i in range(n)) l k = map(int, input().split()) map(int, input().split()) k right = mid mid right right = sum(l) sum(l) right cur = 0 0 cur
n, k = map(int, input().split())
l = list(int(input()) for i in range(n))

left = max(l)-1; right = sum(l)

while left+1 < right:  #最大値と合計値の間のどこかに考えるべき値が存在する
    mid = (left + right) // 2
    cnt = 1; cur = 0  #初期化
    for a in l:
        if mid < cur + a:
            cur = a
            cnt += 1
        else:
            cur += a

    if cnt <= k:
        right = mid
    else:
        left = mid

print(right)
