n, k = map(int,input().split())
w = [0]*n

for i in range(n):
    w[i] = int(input())

minP = max(max(w), sum(w)//k)
maxP = sum(w)
    
left = minP
right = maxP

while left < right:
    mid = (left + right) // 2
    load = 0
    cnt_track = 1
    flag = 1
    for i in range(n):
        load += w[i]
        if load > mid:
            load = w[i]
            cnt_track += 1

        if cnt_track > k:
                flag = 0
                break
    if flag:
        right = mid
    else:
        left = mid + 1
            
print(left) n, k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k w = [0]*n w [0]*n [0] 0 n for i in range(n):
    w[i] = int(input()) i range(n) range n w[i] = int(input()) w[i] w i int(input()) int input() input minP = max(max(w), sum(w)//k) minP max(max(w), sum(w)//k) max max(w) max w sum(w)//k sum(w) sum w k maxP = sum(w) maxP sum(w) sum w left = minP left minP right = maxP right maxP while left < right:
    mid = (left + right) // 2
    load = 0
    cnt_track = 1
    flag = 1
    for i in range(n):
        load += w[i]
        if load > mid:
            load = w[i]
            cnt_track += 1

        if cnt_track > k:
                flag = 0
                break
    if flag:
        right = mid
    else:
        left = mid + 1
             left < right left right mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 load = 0 load 0 cnt_track = 1 cnt_track 1 flag = 1 flag 1 for i in range(n):
        load += w[i]
        if load > mid:
            load = w[i]
            cnt_track += 1

        if cnt_track > k:
                flag = 0
                break
     i range(n) range n load += w[i] load w[i] w i if load > mid:
            load = w[i]
            cnt_track += 1

         load > mid load mid load = w[i] load w[i] w i cnt_track += 1 cnt_track 1 if cnt_track > k:
                flag = 0
                break
     cnt_track > k cnt_track k flag = 0 flag 0 break if flag:
        right = mid
    else:
        left = mid + 1
             flag right = mid right mid left = mid + 1 left mid + 1 mid 1 print(left) print left n, k = map(int,input().split()) map(int,input().split()) n flag = 0 0 flag maxP = sum(w) sum(w) maxP cnt_track += 1 1 cnt_track k = map(int,input().split()) map(int,input().split()) k mid = (left + right) // 2 (left + right) // 2 mid load = 0 0 load left = mid + 1 mid + 1 left load = w[i] w[i] load load += w[i] w[i] load left = minP minP left right = mid mid right minP = max(max(w), sum(w)//k) max(max(w), sum(w)//k) minP flag = 1 1 flag right = maxP maxP right cnt_track = 1 1 cnt_track w = [0]*n [0]*n w
n, k = map(int,input().split())
w = [0]*n

for i in range(n):
    w[i] = int(input())

minP = max(max(w), sum(w)//k)
maxP = sum(w)
    
left = minP
right = maxP

while left < right:
    mid = (left + right) // 2
    load = 0
    cnt_track = 1
    flag = 1
    for i in range(n):
        load += w[i]
        if load > mid:
            load = w[i]
            cnt_track += 1

        if cnt_track > k:
                flag = 0
                break
    if flag:
        right = mid
    else:
        left = mid + 1
            
print(left)
