def cnt_car(w, p):
    car = 1
    wi = 0
    for i in w:
        if (wi + i) <= p:
            wi += i
        else:
            car += 1
            wi = i
    return car

n, k = map(int, input().split())
w = [int(input()) for i in range(n)]
p = max(max(w), sum(w) // k)
while True:
    if cnt_car(w, p) <= k:
        print(p)
        break
    else:
        #print("failed: ", p, cnt_car(w, p))
        if cnt_car(w, p + 100) > k:
            p += 100
        else:
            p += 1 def cnt_car(w, p):
    car = 1
    wi = 0
    for i in w:
        if (wi + i) <= p:
            wi += i
        else:
            car += 1
            wi = i
    return car cnt_car car = 1 car 1 wi = 0 wi 0 for i in w:
        if (wi + i) <= p:
            wi += i
        else:
            car += 1
            wi = i
     i w if (wi + i) <= p:
            wi += i
        else:
            car += 1
            wi = i
     (wi + i) <= p wi + i wi i p wi += i wi i car += 1 car 1 wi = i wi i return car car w w p p n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input w = [int(input()) for i in range(n)] w [int(input()) for i in range(n)] p = max(max(w), sum(w) // k) p max(max(w), sum(w) // k) max max(w) max w sum(w) // k sum(w) sum w k while True:
    if cnt_car(w, p) <= k:
        print(p)
        break
    else:
        #print("failed: ", p, cnt_car(w, p))
        if cnt_car(w, p + 100) > k:
            p += 100
        else:
            p += 1 True if cnt_car(w, p) <= k:
        print(p)
        break
    else:
        #print("failed: ", p, cnt_car(w, p))
        if cnt_car(w, p + 100) > k:
            p += 100
        else:
            p += 1 cnt_car(w, p) <= k cnt_car(w, p) cnt_car w p k print(p) print p break if cnt_car(w, p + 100) > k:
            p += 100
        else:
            p += 1 cnt_car(w, p + 100) > k cnt_car(w, p + 100) cnt_car w p + 100 p 100 k p += 100 p 100 p += 1 p 1 p = max(max(w), sum(w) // k) max(max(w), sum(w) // k) p p += 100 100 p w = [int(input()) for i in range(n)] [int(input()) for i in range(n)] w def cnt_car(w, p):
    car = 1
    wi = 0
    for i in w:
        if (wi + i) <= p:
            wi += i
        else:
            car += 1
            wi = i
    return car def cnt_car(w, p):
    car = 1
    wi = 0
    for i in w:
        if (wi + i) <= p:
            wi += i
        else:
            car += 1
            wi = i
    return car cnt_car n, k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k p += 1 1 p
def cnt_car(w, p):
    car = 1
    wi = 0
    for i in w:
        if (wi + i) <= p:
            wi += i
        else:
            car += 1
            wi = i
    return car

n, k = map(int, input().split())
w = [int(input()) for i in range(n)]
p = max(max(w), sum(w) // k)
while True:
    if cnt_car(w, p) <= k:
        print(p)
        break
    else:
        #print("failed: ", p, cnt_car(w, p))
        if cnt_car(w, p + 100) > k:
            p += 100
        else:
            p += 1
