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


def check(p):
    remain_track = k - 1
    remain_p = p
    for a in range(n):
        if w[a] > p:
            return False
        if remain_p >= w[a]:
            remain_p -= w[a]
        else:
            if remain_track == 0:
                return False
            else:
                remain_track -= 1
                remain_p = p - w[a]
        # print(a, w[a], remain_p, remain_track)
    return True


next = 10 ** 9
prev = next


for i in range(200):
    if check(next):
        prev = next
        next = next // 2
    else:
        next = (next + prev) // 2
print(prev) import time time n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k w = [0] * n w [0] * n [0] 0 n for i in range(n):
    w[i] = int(input()) i range(n) range n w[i] = int(input()) w[i] w i int(input()) int input() input def check(p):
    remain_track = k - 1
    remain_p = p
    for a in range(n):
        if w[a] > p:
            return False
        if remain_p >= w[a]:
            remain_p -= w[a]
        else:
            if remain_track == 0:
                return False
            else:
                remain_track -= 1
                remain_p = p - w[a]
        # print(a, w[a], remain_p, remain_track)
    return True check remain_track = k - 1 remain_track k - 1 k 1 remain_p = p remain_p p for a in range(n):
        if w[a] > p:
            return False
        if remain_p >= w[a]:
            remain_p -= w[a]
        else:
            if remain_track == 0:
                return False
            else:
                remain_track -= 1
                remain_p = p - w[a]
        # print(a, w[a], remain_p, remain_track)
     a range(n) range n if w[a] > p:
            return False
         w[a] > p w[a] w a p return False False if remain_p >= w[a]:
            remain_p -= w[a]
        else:
            if remain_track == 0:
                return False
            else:
                remain_track -= 1
                remain_p = p - w[a]
        # print(a, w[a], remain_p, remain_track)
     remain_p >= w[a] remain_p w[a] w a remain_p -= w[a] remain_p w[a] w a if remain_track == 0:
                return False
            else:
                remain_track -= 1
                remain_p = p - w[a]
        # print(a, w[a], remain_p, remain_track)
     remain_track == 0 remain_track 0 return False False remain_track -= 1 remain_track 1 remain_p = p - w[a] remain_p p - w[a] p w[a] w a return True True p p next = 10 ** 9 next 10 ** 9 10 9 prev = next prev next for i in range(200):
    if check(next):
        prev = next
        next = next // 2
    else:
        next = (next + prev) // 2 i range(200) range 200 if check(next):
        prev = next
        next = next // 2
    else:
        next = (next + prev) // 2 check(next) check next prev = next prev next next = next // 2 next next // 2 next 2 next = (next + prev) // 2 next (next + prev) // 2 next + prev next prev 2 print(prev) print prev w = [0] * n [0] * n w next = next // 2 next // 2 next def check(p):
    remain_track = k - 1
    remain_p = p
    for a in range(n):
        if w[a] > p:
            return False
        if remain_p >= w[a]:
            remain_p -= w[a]
        else:
            if remain_track == 0:
                return False
            else:
                remain_track -= 1
                remain_p = p - w[a]
        # print(a, w[a], remain_p, remain_track)
    return True def check(p):
    remain_track = k - 1
    remain_p = p
    for a in range(n):
        if w[a] > p:
            return False
        if remain_p >= w[a]:
            remain_p -= w[a]
        else:
            if remain_track == 0:
                return False
            else:
                remain_track -= 1
                remain_p = p - w[a]
        # print(a, w[a], remain_p, remain_track)
    return True check k = map(int, input().split()) map(int, input().split()) k prev = next next prev next = 10 ** 9 10 ** 9 next next = (next + prev) // 2 (next + prev) // 2 next n, k = map(int, input().split()) map(int, input().split()) n prev = next next prev
import time
n, k = map(int, input().split())
w = [0] * n
for i in range(n):
    w[i] = int(input())


def check(p):
    remain_track = k - 1
    remain_p = p
    for a in range(n):
        if w[a] > p:
            return False
        if remain_p >= w[a]:
            remain_p -= w[a]
        else:
            if remain_track == 0:
                return False
            else:
                remain_track -= 1
                remain_p = p - w[a]
        # print(a, w[a], remain_p, remain_track)
    return True


next = 10 ** 9
prev = next


for i in range(200):
    if check(next):
        prev = next
        next = next // 2
    else:
        next = (next + prev) // 2
print(prev)
