#coding: utf-8
n, k = map(int, input().split())
pkt = list()
for i in range(n):
    pkt.append(int(input()))
lenpkt = len(pkt)

def maxPkt(payload):
    maxPnum = 0
    for i in range(k):
        tempPL = 0
        while tempPL + pkt[maxPnum] <= payload:
            tempPL += pkt[maxPnum]
            maxPnum += 1
            if maxPnum == lenpkt:
                return True
    return False

lft = 0
mid = 0
rgt = 100000 * 10000

while lft < rgt:
    mid = (lft + rgt) // 2
    if maxPkt(mid):
        rgt = mid
    else:
        lft = mid + 1

print(rgt) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k pkt = list() pkt list() list for i in range(n):
    pkt.append(int(input())) i range(n) range n pkt.append(int(input())) pkt.append pkt append int(input()) int input() input lenpkt = len(pkt) lenpkt len(pkt) len pkt def maxPkt(payload):
    maxPnum = 0
    for i in range(k):
        tempPL = 0
        while tempPL + pkt[maxPnum] <= payload:
            tempPL += pkt[maxPnum]
            maxPnum += 1
            if maxPnum == lenpkt:
                return True
    return False maxPkt maxPnum = 0 maxPnum 0 for i in range(k):
        tempPL = 0
        while tempPL + pkt[maxPnum] <= payload:
            tempPL += pkt[maxPnum]
            maxPnum += 1
            if maxPnum == lenpkt:
                return True
     i range(k) range k tempPL = 0 tempPL 0 while tempPL + pkt[maxPnum] <= payload:
            tempPL += pkt[maxPnum]
            maxPnum += 1
            if maxPnum == lenpkt:
                return True
     tempPL + pkt[maxPnum] <= payload tempPL + pkt[maxPnum] tempPL pkt[maxPnum] pkt maxPnum payload tempPL += pkt[maxPnum] tempPL pkt[maxPnum] pkt maxPnum maxPnum += 1 maxPnum 1 if maxPnum == lenpkt:
                return True
     maxPnum == lenpkt maxPnum lenpkt return True True return False False payload payload lft = 0 lft 0 mid = 0 mid 0 rgt = 100000 * 10000 rgt 100000 * 10000 100000 10000 while lft < rgt:
    mid = (lft + rgt) // 2
    if maxPkt(mid):
        rgt = mid
    else:
        lft = mid + 1 lft < rgt lft rgt mid = (lft + rgt) // 2 mid (lft + rgt) // 2 lft + rgt lft rgt 2 if maxPkt(mid):
        rgt = mid
    else:
        lft = mid + 1 maxPkt(mid) maxPkt mid rgt = mid rgt mid lft = mid + 1 lft mid + 1 mid 1 print(rgt) print rgt def maxPkt(payload):
    maxPnum = 0
    for i in range(k):
        tempPL = 0
        while tempPL + pkt[maxPnum] <= payload:
            tempPL += pkt[maxPnum]
            maxPnum += 1
            if maxPnum == lenpkt:
                return True
    return False def maxPkt(payload):
    maxPnum = 0
    for i in range(k):
        tempPL = 0
        while tempPL + pkt[maxPnum] <= payload:
            tempPL += pkt[maxPnum]
            maxPnum += 1
            if maxPnum == lenpkt:
                return True
    return False maxPkt pkt = list() list() pkt n, k = map(int, input().split()) map(int, input().split()) n mid = (lft + rgt) // 2 (lft + rgt) // 2 mid lft = 0 0 lft lenpkt = len(pkt) len(pkt) lenpkt mid = 0 0 mid lft = mid + 1 mid + 1 lft rgt = 100000 * 10000 100000 * 10000 rgt rgt = mid mid rgt k = map(int, input().split()) map(int, input().split()) k
#coding: utf-8
n, k = map(int, input().split())
pkt = list()
for i in range(n):
    pkt.append(int(input()))
lenpkt = len(pkt)

def maxPkt(payload):
    maxPnum = 0
    for i in range(k):
        tempPL = 0
        while tempPL + pkt[maxPnum] <= payload:
            tempPL += pkt[maxPnum]
            maxPnum += 1
            if maxPnum == lenpkt:
                return True
    return False

lft = 0
mid = 0
rgt = 100000 * 10000

while lft < rgt:
    mid = (lft + rgt) // 2
    if maxPkt(mid):
        rgt = mid
    else:
        lft = mid + 1

print(rgt)
