def unit_check(n, k, w_list, P):
    i = 0
    for j in range(k):
        weight = 0
        while weight + w_list[i] <= P:
            weight += w_list[i]
            i += 1
            if i == n:
                return 1
    return 0

n, k = map(int,input().split())
w_list = [0] * n
for i in range(n):
    w_list[i] = int(input())

left = 0
right = 100000*10000
while left+1 < right:
    mid = (left+ right)//2
    check = unit_check(n, k, w_list, mid)
    if check == 1:
        right = mid
    else:
        left = mid
print(right) def unit_check(n, k, w_list, P):
    i = 0
    for j in range(k):
        weight = 0
        while weight + w_list[i] <= P:
            weight += w_list[i]
            i += 1
            if i == n:
                return 1
    return 0 unit_check i = 0 i 0 for j in range(k):
        weight = 0
        while weight + w_list[i] <= P:
            weight += w_list[i]
            i += 1
            if i == n:
                return 1
     j range(k) range k weight = 0 weight 0 while weight + w_list[i] <= P:
            weight += w_list[i]
            i += 1
            if i == n:
                return 1
     weight + w_list[i] <= P weight + w_list[i] weight w_list[i] w_list i P weight += w_list[i] weight w_list[i] w_list i i += 1 i 1 if i == n:
                return 1
     i == n i n return 1 1 return 0 0 n n k k w_list w_list P P n, k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k w_list = [0] * n w_list [0] * n [0] 0 n for i in range(n):
    w_list[i] = int(input()) i range(n) range n w_list[i] = int(input()) w_list[i] w_list i int(input()) int input() input left = 0 left 0 right = 100000*10000 right 100000*10000 100000 10000 while left+1 < right:
    mid = (left+ right)//2
    check = unit_check(n, k, w_list, mid)
    if check == 1:
        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 check = unit_check(n, k, w_list, mid) check unit_check(n, k, w_list, mid) unit_check n k w_list mid if check == 1:
        right = mid
    else:
        left = mid check == 1 check 1 right = mid right mid left = mid left mid print(right) print right left = 0 0 left def unit_check(n, k, w_list, P):
    i = 0
    for j in range(k):
        weight = 0
        while weight + w_list[i] <= P:
            weight += w_list[i]
            i += 1
            if i == n:
                return 1
    return 0 def unit_check(n, k, w_list, P):
    i = 0
    for j in range(k):
        weight = 0
        while weight + w_list[i] <= P:
            weight += w_list[i]
            i += 1
            if i == n:
                return 1
    return 0 unit_check n, k = map(int,input().split()) map(int,input().split()) n k = map(int,input().split()) map(int,input().split()) k right = 100000*10000 100000*10000 right right = mid mid right mid = (left+ right)//2 (left+ right)//2 mid w_list = [0] * n [0] * n w_list left = mid mid left check = unit_check(n, k, w_list, mid) unit_check(n, k, w_list, mid) check
def unit_check(n, k, w_list, P):
    i = 0
    for j in range(k):
        weight = 0
        while weight + w_list[i] <= P:
            weight += w_list[i]
            i += 1
            if i == n:
                return 1
    return 0

n, k = map(int,input().split())
w_list = [0] * n
for i in range(n):
    w_list[i] = int(input())

left = 0
right = 100000*10000
while left+1 < right:
    mid = (left+ right)//2
    check = unit_check(n, k, w_list, mid)
    if check == 1:
        right = mid
    else:
        left = mid
print(right)
