n = list(map(int, input().split()))
w = [0] * n[0]
for i in range(n[0]):
    w[i] = int(input())
    
def check(p):
    i = 0
    for j in range(n[1]):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n[0]:
                return True
    return False

def solve():
    left = 0
    right = 100000 * 10000
    min_p = 100000 * 10000
    while right - left > 1:
        mid = (right + left) // 2
        if check(mid):
            if min_p > mid:
                min_p = mid
            right = mid
        else:
            left = mid
    print(min_p)

solve() n = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split w = [0] * n[0] w [0] * n[0] [0] 0 n[0] n 0 for i in range(n[0]):
    w[i] = int(input())
     i range(n[0]) range n[0] n 0 w[i] = int(input()) w[i] w i int(input()) int input() input def check(p):
    i = 0
    for j in range(n[1]):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n[0]:
                return True
    return False check i = 0 i 0 for j in range(n[1]):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n[0]:
                return True
     j range(n[1]) range n[1] n 1 s = 0 s 0 while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n[0]:
                return True
     s + w[i] <= p s + w[i] s w[i] w i p s += w[i] s w[i] w i i += 1 i 1 if i == n[0]:
                return True
     i == n[0] i n[0] n 0 return True True return False False p p def solve():
    left = 0
    right = 100000 * 10000
    min_p = 100000 * 10000
    while right - left > 1:
        mid = (right + left) // 2
        if check(mid):
            if min_p > mid:
                min_p = mid
            right = mid
        else:
            left = mid
    print(min_p) solve left = 0 left 0 right = 100000 * 10000 right 100000 * 10000 100000 10000 min_p = 100000 * 10000 min_p 100000 * 10000 100000 10000 while right - left > 1:
        mid = (right + left) // 2
        if check(mid):
            if min_p > mid:
                min_p = mid
            right = mid
        else:
            left = mid
     right - left > 1 right - left right left 1 mid = (right + left) // 2 mid (right + left) // 2 right + left right left 2 if check(mid):
            if min_p > mid:
                min_p = mid
            right = mid
        else:
            left = mid
     check(mid) check mid if min_p > mid:
                min_p = mid
             min_p > mid min_p mid min_p = mid min_p mid right = mid right mid left = mid left mid print(min_p) print min_p solve() solve def solve():
    left = 0
    right = 100000 * 10000
    min_p = 100000 * 10000
    while right - left > 1:
        mid = (right + left) // 2
        if check(mid):
            if min_p > mid:
                min_p = mid
            right = mid
        else:
            left = mid
    print(min_p) def solve():
    left = 0
    right = 100000 * 10000
    min_p = 100000 * 10000
    while right - left > 1:
        mid = (right + left) // 2
        if check(mid):
            if min_p > mid:
                min_p = mid
            right = mid
        else:
            left = mid
    print(min_p) solve def check(p):
    i = 0
    for j in range(n[1]):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n[0]:
                return True
    return False def check(p):
    i = 0
    for j in range(n[1]):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n[0]:
                return True
    return False check w = [0] * n[0] [0] * n[0] w n = list(map(int, input().split())) list(map(int, input().split())) n
n = list(map(int, input().split()))
w = [0] * n[0]
for i in range(n[0]):
    w[i] = int(input())
    
def check(p):
    i = 0
    for j in range(n[1]):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n[0]:
                return True
    return False

def solve():
    left = 0
    right = 100000 * 10000
    min_p = 100000 * 10000
    while right - left > 1:
        mid = (right + left) // 2
        if check(mid):
            if min_p > mid:
                min_p = mid
            right = mid
        else:
            left = mid
    print(min_p)

solve()
