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

def check(P):
    s, cnt = 0, 1
    for i in range(n):
        if w[i] > P:
            return False
        if s + w[i] <= P:
            s += w[i]
        else:
            s = w[i]
            cnt += 1
    return cnt <= k

l, r = 0, 10000 * n
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m

print(r) 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):
    s, cnt = 0, 1
    for i in range(n):
        if w[i] > P:
            return False
        if s + w[i] <= P:
            s += w[i]
        else:
            s = w[i]
            cnt += 1
    return cnt <= k check s, cnt = 0, 1 s 0 cnt 1 for i in range(n):
        if w[i] > P:
            return False
        if s + w[i] <= P:
            s += w[i]
        else:
            s = w[i]
            cnt += 1
     i range(n) range n if w[i] > P:
            return False
         w[i] > P w[i] w i P return False False if s + w[i] <= P:
            s += w[i]
        else:
            s = w[i]
            cnt += 1
     s + w[i] <= P s + w[i] s w[i] w i P s += w[i] s w[i] w i s = w[i] s w[i] w i cnt += 1 cnt 1 return cnt <= k cnt <= k cnt k P P l, r = 0, 10000 * n l 0 r 10000 * n 10000 n while r - l > 1:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m r - l > 1 r - l r l 1 m = (l + r) // 2 m (l + r) // 2 l + r l r 2 if check(m):
        r = m
    else:
        l = m check(m) check m r = m r m l = m l m print(r) print r w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w l, r = 0, 10000 * n 0 l r = 0, 10000 * n 10000 * n r m = (l + r) // 2 (l + r) // 2 m k = map(int, input().split()) map(int, input().split()) k l = m m l n, k = map(int, input().split()) map(int, input().split()) n def check(P):
    s, cnt = 0, 1
    for i in range(n):
        if w[i] > P:
            return False
        if s + w[i] <= P:
            s += w[i]
        else:
            s = w[i]
            cnt += 1
    return cnt <= k def check(P):
    s, cnt = 0, 1
    for i in range(n):
        if w[i] > P:
            return False
        if s + w[i] <= P:
            s += w[i]
        else:
            s = w[i]
            cnt += 1
    return cnt <= k check r = m m r
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(P):
    s, cnt = 0, 1
    for i in range(n):
        if w[i] > P:
            return False
        if s + w[i] <= P:
            s += w[i]
        else:
            s = w[i]
            cnt += 1
    return cnt <= k

l, r = 0, 10000 * n
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        r = m
    else:
        l = m

print(r)