n, k = map(int,input().split())
w = [int(input()) for _ in range(n)]

# 荷物の最大積算量を返す
def check(p):
    global n,k,w
    v = 0
    track = 0
    temp = 0
    i = 0
    while track < k:
        temp = 0
        while temp + w[i] <= p:
            temp += w[i]
            i = i + 1
            if i == n:
                return i
        track += 1
        #print(track,i)
    return i

def main():
    global n,k,w
    left = 0
    right = 100000*10000

    while True:
        mid = int( (left+right) / 2 )
        #print(left,right,mid)
        v = check(mid)
        judge = check(mid-1)
        #print(n,v,judge)
        if v < n:
            left = mid + 1
        elif v == n and judge != n:
            return mid
        elif v == n and judge == n:
            right = mid

print(main())
 n, k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input w = [int(input()) for _ in range(n)] w [int(input()) for _ in range(n)] def check(p):
    global n,k,w
    v = 0
    track = 0
    temp = 0
    i = 0
    while track < k:
        temp = 0
        while temp + w[i] <= p:
            temp += w[i]
            i = i + 1
            if i == n:
                return i
        track += 1
        #print(track,i)
    return i check global n,k,w v = 0 v 0 track = 0 track 0 temp = 0 temp 0 i = 0 i 0 while track < k:
        temp = 0
        while temp + w[i] <= p:
            temp += w[i]
            i = i + 1
            if i == n:
                return i
        track += 1
        #print(track,i)
     track < k track k temp = 0 temp 0 while temp + w[i] <= p:
            temp += w[i]
            i = i + 1
            if i == n:
                return i
         temp + w[i] <= p temp + w[i] temp w[i] w i p temp += w[i] temp w[i] w i i = i + 1 i i + 1 i 1 if i == n:
                return i
         i == n i n return i i track += 1 track 1 return i i p p def main():
    global n,k,w
    left = 0
    right = 100000*10000

    while True:
        mid = int( (left+right) / 2 )
        #print(left,right,mid)
        v = check(mid)
        judge = check(mid-1)
        #print(n,v,judge)
        if v < n:
            left = mid + 1
        elif v == n and judge != n:
            return mid
        elif v == n and judge == n:
            right = mid main global n,k,w left = 0 left 0 right = 100000*10000 right 100000*10000 100000 10000 while True:
        mid = int( (left+right) / 2 )
        #print(left,right,mid)
        v = check(mid)
        judge = check(mid-1)
        #print(n,v,judge)
        if v < n:
            left = mid + 1
        elif v == n and judge != n:
            return mid
        elif v == n and judge == n:
            right = mid True mid = int( (left+right) / 2 ) mid int( (left+right) / 2 ) int (left+right) / 2 left+right left right 2 v = check(mid) v check(mid) check mid judge = check(mid-1) judge check(mid-1) check mid-1 mid 1 if v < n:
            left = mid + 1
        elif v == n and judge != n:
            return mid
        elif v == n and judge == n:
            right = mid v < n v n left = mid + 1 left mid + 1 mid 1 elif v == n and judge != n:
            return mid
         v == n and judge != n v == n v n judge != n judge n return mid mid elif v == n and judge == n:
            right = mid v == n and judge == n v == n v n judge == n judge n right = mid right mid print(main()) print main() main k = map(int,input().split()) map(int,input().split()) k w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w n, k = map(int,input().split()) map(int,input().split()) n def check(p):
    global n,k,w
    v = 0
    track = 0
    temp = 0
    i = 0
    while track < k:
        temp = 0
        while temp + w[i] <= p:
            temp += w[i]
            i = i + 1
            if i == n:
                return i
        track += 1
        #print(track,i)
    return i def check(p):
    global n,k,w
    v = 0
    track = 0
    temp = 0
    i = 0
    while track < k:
        temp = 0
        while temp + w[i] <= p:
            temp += w[i]
            i = i + 1
            if i == n:
                return i
        track += 1
        #print(track,i)
    return i check def main():
    global n,k,w
    left = 0
    right = 100000*10000

    while True:
        mid = int( (left+right) / 2 )
        #print(left,right,mid)
        v = check(mid)
        judge = check(mid-1)
        #print(n,v,judge)
        if v < n:
            left = mid + 1
        elif v == n and judge != n:
            return mid
        elif v == n and judge == n:
            right = mid def main():
    global n,k,w
    left = 0
    right = 100000*10000

    while True:
        mid = int( (left+right) / 2 )
        #print(left,right,mid)
        v = check(mid)
        judge = check(mid-1)
        #print(n,v,judge)
        if v < n:
            left = mid + 1
        elif v == n and judge != n:
            return mid
        elif v == n and judge == n:
            right = mid main
n, k = map(int,input().split())
w = [int(input()) for _ in range(n)]

# 荷物の最大積算量を返す
def check(p):
    global n,k,w
    v = 0
    track = 0
    temp = 0
    i = 0
    while track < k:
        temp = 0
        while temp + w[i] <= p:
            temp += w[i]
            i = i + 1
            if i == n:
                return i
        track += 1
        #print(track,i)
    return i

def main():
    global n,k,w
    left = 0
    right = 100000*10000

    while True:
        mid = int( (left+right) / 2 )
        #print(left,right,mid)
        v = check(mid)
        judge = check(mid-1)
        #print(n,v,judge)
        if v < n:
            left = mid + 1
        elif v == n and judge != n:
            return mid
        elif v == n and judge == n:
            right = mid

print(main())

