n, k = map(int, input().split())
wlist = []
for i in range(n):
    wlist.append(int(input()))

ma = sum(wlist) + 1
mi = max(wlist) - 1
while (ma - mi > 1):
    mid = (ma + mi)//2
    truck = [0for i in range(k)] ## k개
    i = 0
    gobigger = 0
    for w in wlist:
        if(truck[i] + w <= mid):
            truck[i] = truck[i] + w
        else:
            i = i+1
            if (i == k):
                gobigger = 1
                break
            truck[i] = truck[i] + w
    if (gobigger == 1):
        mi = mid
    else:
        ma = mid
    
print(ma)
         n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k wlist = [] wlist [] for i in range(n):
    wlist.append(int(input())) i range(n) range n wlist.append(int(input())) wlist.append wlist append int(input()) int input() input ma = sum(wlist) + 1 ma sum(wlist) + 1 sum(wlist) sum wlist 1 mi = max(wlist) - 1 mi max(wlist) - 1 max(wlist) max wlist 1 while (ma - mi > 1):
    mid = (ma + mi)//2
    truck = [0for i in range(k)] ## k개
    i = 0
    gobigger = 0
    for w in wlist:
        if(truck[i] + w <= mid):
            truck[i] = truck[i] + w
        else:
            i = i+1
            if (i == k):
                gobigger = 1
                break
            truck[i] = truck[i] + w
    if (gobigger == 1):
        mi = mid
    else:
        ma = mid
     ma - mi > 1 ma - mi ma mi 1 mid = (ma + mi)//2 mid (ma + mi)//2 ma + mi ma mi 2 0for i in range(k) for i in range(k) i range(k) range k for i in range(k) 0 truck = [0for i in range(k)] truck [0for i in range(k)] i = 0 i 0 gobigger = 0 gobigger 0 for w in wlist:
        if(truck[i] + w <= mid):
            truck[i] = truck[i] + w
        else:
            i = i+1
            if (i == k):
                gobigger = 1
                break
            truck[i] = truck[i] + w
     w wlist if(truck[i] + w <= mid):
            truck[i] = truck[i] + w
        else:
            i = i+1
            if (i == k):
                gobigger = 1
                break
            truck[i] = truck[i] + w
     truck[i] + w <= mid truck[i] + w truck[i] truck i w mid truck[i] = truck[i] + w truck[i] truck i truck[i] + w truck[i] truck i w i = i+1 i i+1 i 1 if (i == k):
                gobigger = 1
                break
             i == k i k gobigger = 1 gobigger 1 break truck[i] = truck[i] + w truck[i] truck i truck[i] + w truck[i] truck i w if (gobigger == 1):
        mi = mid
    else:
        ma = mid
     gobigger == 1 gobigger 1 mi = mid mi mid ma = mid ma mid print(ma) print ma mi = max(wlist) - 1 max(wlist) - 1 mi n, k = map(int, input().split()) map(int, input().split()) n wlist = [] [] wlist i = 0 0 i mi = mid mid mi gobigger = 1 1 gobigger truck = [0for i in range(k)] [0for i in range(k)] truck i = i+1 i+1 i gobigger = 0 0 gobigger k = map(int, input().split()) map(int, input().split()) k ma = sum(wlist) + 1 sum(wlist) + 1 ma mid = (ma + mi)//2 (ma + mi)//2 mid ma = mid mid ma
n, k = map(int, input().split())
wlist = []
for i in range(n):
    wlist.append(int(input()))

ma = sum(wlist) + 1
mi = max(wlist) - 1
while (ma - mi > 1):
    mid = (ma + mi)//2
    truck = [0for i in range(k)] ## k개
    i = 0
    gobigger = 0
    for w in wlist:
        if(truck[i] + w <= mid):
            truck[i] = truck[i] + w
        else:
            i = i+1
            if (i == k):
                gobigger = 1
                break
            truck[i] = truck[i] + w
    if (gobigger == 1):
        mi = mid
    else:
        ma = mid
    
print(ma)
        
