n, k = map(int, input().split())

w = []

for i in range(n):
    w.append(int(input()))
   
def carriable(P, n, k, w):
    j = 0
    for i in range(k):
        sum = 0
        while j < n and sum + w[j] <= P:
            sum += w[j]
            j += 1
    return j

def binary_search(p_left, p_right, n, k, w):
    if p_left == p_right:
        return p_left
    else:
        p_center = (p_left + p_right)//2
        # because we have to search for the smallest p which satisfies carriable(p, n, k, w) = n, 
        # be careful of the inequality condition
        if carriable(p_center, n, k, w) >= n:
            return binary_search(p_left, p_center, n, k, w)
        else:
            return binary_search(p_center + 1, p_right, n, k, w)

p_left = 0
p_right = sum(w)
print(binary_search(p_left, p_right, n, k, w)) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k w = [] w [] for i in range(n):
    w.append(int(input()))
    i range(n) range n w.append(int(input())) w.append w append int(input()) int input() input def carriable(P, n, k, w):
    j = 0
    for i in range(k):
        sum = 0
        while j < n and sum + w[j] <= P:
            sum += w[j]
            j += 1
    return j carriable j = 0 j 0 for i in range(k):
        sum = 0
        while j < n and sum + w[j] <= P:
            sum += w[j]
            j += 1
     i range(k) range k sum = 0 sum 0 while j < n and sum + w[j] <= P:
            sum += w[j]
            j += 1
     j < n and sum + w[j] <= P j < n j n sum + w[j] <= P sum + w[j] sum w[j] w j P sum += w[j] sum w[j] w j j += 1 j 1 return j j P P n n k k w w def binary_search(p_left, p_right, n, k, w):
    if p_left == p_right:
        return p_left
    else:
        p_center = (p_left + p_right)//2
        # because we have to search for the smallest p which satisfies carriable(p, n, k, w) = n, 
        # be careful of the inequality condition
        if carriable(p_center, n, k, w) >= n:
            return binary_search(p_left, p_center, n, k, w)
        else:
            return binary_search(p_center + 1, p_right, n, k, w) binary_search if p_left == p_right:
        return p_left
    else:
        p_center = (p_left + p_right)//2
        # because we have to search for the smallest p which satisfies carriable(p, n, k, w) = n, 
        # be careful of the inequality condition
        if carriable(p_center, n, k, w) >= n:
            return binary_search(p_left, p_center, n, k, w)
        else:
            return binary_search(p_center + 1, p_right, n, k, w) p_left == p_right p_left p_right return p_left p_left p_center = (p_left + p_right)//2 p_center (p_left + p_right)//2 p_left + p_right p_left p_right 2 if carriable(p_center, n, k, w) >= n:
            return binary_search(p_left, p_center, n, k, w)
        else:
            return binary_search(p_center + 1, p_right, n, k, w) carriable(p_center, n, k, w) >= n carriable(p_center, n, k, w) carriable p_center n k w n return binary_search(p_left, p_center, n, k, w) binary_search(p_left, p_center, n, k, w) binary_search p_left p_center n k w return binary_search(p_center + 1, p_right, n, k, w) binary_search(p_center + 1, p_right, n, k, w) binary_search p_center + 1 p_center 1 p_right n k w p_left p_left p_right p_right n n k k w w p_left = 0 p_left 0 p_right = sum(w) p_right sum(w) sum w print(binary_search(p_left, p_right, n, k, w)) print binary_search(p_left, p_right, n, k, w) binary_search p_left p_right n k w def carriable(P, n, k, w):
    j = 0
    for i in range(k):
        sum = 0
        while j < n and sum + w[j] <= P:
            sum += w[j]
            j += 1
    return j def carriable(P, n, k, w):
    j = 0
    for i in range(k):
        sum = 0
        while j < n and sum + w[j] <= P:
            sum += w[j]
            j += 1
    return j carriable p_right = sum(w) sum(w) p_right p_left = 0 0 p_left n, k = map(int, input().split()) map(int, input().split()) n def binary_search(p_left, p_right, n, k, w):
    if p_left == p_right:
        return p_left
    else:
        p_center = (p_left + p_right)//2
        # because we have to search for the smallest p which satisfies carriable(p, n, k, w) = n, 
        # be careful of the inequality condition
        if carriable(p_center, n, k, w) >= n:
            return binary_search(p_left, p_center, n, k, w)
        else:
            return binary_search(p_center + 1, p_right, n, k, w) def binary_search(p_left, p_right, n, k, w):
    if p_left == p_right:
        return p_left
    else:
        p_center = (p_left + p_right)//2
        # because we have to search for the smallest p which satisfies carriable(p, n, k, w) = n, 
        # be careful of the inequality condition
        if carriable(p_center, n, k, w) >= n:
            return binary_search(p_left, p_center, n, k, w)
        else:
            return binary_search(p_center + 1, p_right, n, k, w) binary_search k = map(int, input().split()) map(int, input().split()) k w = [] [] w
n, k = map(int, input().split())

w = []

for i in range(n):
    w.append(int(input()))
   
def carriable(P, n, k, w):
    j = 0
    for i in range(k):
        sum = 0
        while j < n and sum + w[j] <= P:
            sum += w[j]
            j += 1
    return j

def binary_search(p_left, p_right, n, k, w):
    if p_left == p_right:
        return p_left
    else:
        p_center = (p_left + p_right)//2
        # because we have to search for the smallest p which satisfies carriable(p, n, k, w) = n, 
        # be careful of the inequality condition
        if carriable(p_center, n, k, w) >= n:
            return binary_search(p_left, p_center, n, k, w)
        else:
            return binary_search(p_center + 1, p_right, n, k, w)

p_left = 0
p_right = sum(w)
print(binary_search(p_left, p_right, n, k, w))
