import math, sys

def loadable(w, n, k, p, wsum):
    wait = 0
    for i in range(n):
        wait += w[i]
        wsum -= w[i]
        if wait > p:
            k -= 1
            wait = w[i]
            if k == 0 or p < wsum / k:
                return False
    return True

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

wsum = sum(w)

p = max(int(math.ceil(wsum / k)), max(w))
pre_f = p -1
pre_s = None

while True:
    if loadable(w, n, k, p, wsum):
        pre_s = p
    else:
        pre_f = p

    if pre_s != None and pre_s - pre_f == 1:
            break
    
    if pre_s:
        p = int((pre_s + pre_f) / 2)
    else:
        p = math.ceil(p * 1.01)
    
print(pre_s) import math, sys math sys def loadable(w, n, k, p, wsum):
    wait = 0
    for i in range(n):
        wait += w[i]
        wsum -= w[i]
        if wait > p:
            k -= 1
            wait = w[i]
            if k == 0 or p < wsum / k:
                return False
    return True loadable wait = 0 wait 0 for i in range(n):
        wait += w[i]
        wsum -= w[i]
        if wait > p:
            k -= 1
            wait = w[i]
            if k == 0 or p < wsum / k:
                return False
     i range(n) range n wait += w[i] wait w[i] w i wsum -= w[i] wsum w[i] w i if wait > p:
            k -= 1
            wait = w[i]
            if k == 0 or p < wsum / k:
                return False
     wait > p wait p k -= 1 k 1 wait = w[i] wait w[i] w i if k == 0 or p < wsum / k:
                return False
     k == 0 or p < wsum / k k == 0 k 0 p < wsum / k p wsum / k wsum k return False False return True True w w n n k k p p wsum wsum n, k = map(int, sys.stdin.readline().split()) n map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split k int(sys.stdin.readline()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline w = [int(sys.stdin.readline()) for _ in range(n)] w [int(sys.stdin.readline()) for _ in range(n)] wsum = sum(w) wsum sum(w) sum w p = max(int(math.ceil(wsum / k)), max(w)) p max(int(math.ceil(wsum / k)), max(w)) max int(math.ceil(wsum / k)) int math.ceil(wsum / k) math.ceil math ceil wsum / k wsum k max(w) max w pre_f = p -1 pre_f p -1 p 1 pre_s = None pre_s None while True:
    if loadable(w, n, k, p, wsum):
        pre_s = p
    else:
        pre_f = p

    if pre_s != None and pre_s - pre_f == 1:
            break
    
    if pre_s:
        p = int((pre_s + pre_f) / 2)
    else:
        p = math.ceil(p * 1.01)
     True if loadable(w, n, k, p, wsum):
        pre_s = p
    else:
        pre_f = p

     loadable(w, n, k, p, wsum) loadable w n k p wsum pre_s = p pre_s p pre_f = p pre_f p if pre_s != None and pre_s - pre_f == 1:
            break
    
     pre_s != None and pre_s - pre_f == 1 pre_s != None pre_s None pre_s - pre_f == 1 pre_s - pre_f pre_s pre_f 1 break if pre_s:
        p = int((pre_s + pre_f) / 2)
    else:
        p = math.ceil(p * 1.01)
     pre_s p = int((pre_s + pre_f) / 2) p int((pre_s + pre_f) / 2) int (pre_s + pre_f) / 2 pre_s + pre_f pre_s pre_f 2 p = math.ceil(p * 1.01) p math.ceil(p * 1.01) math.ceil math ceil p * 1.01 p 1.01 print(pre_s) print pre_s pre_s = p p pre_s wsum = sum(w) sum(w) wsum w = [int(sys.stdin.readline()) for _ in range(n)] [int(sys.stdin.readline()) for _ in range(n)] w n, k = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) n p = max(int(math.ceil(wsum / k)), max(w)) max(int(math.ceil(wsum / k)), max(w)) p pre_f = p -1 p -1 pre_f pre_s = None None pre_s p = int((pre_s + pre_f) / 2) int((pre_s + pre_f) / 2) p k = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) k def loadable(w, n, k, p, wsum):
    wait = 0
    for i in range(n):
        wait += w[i]
        wsum -= w[i]
        if wait > p:
            k -= 1
            wait = w[i]
            if k == 0 or p < wsum / k:
                return False
    return True def loadable(w, n, k, p, wsum):
    wait = 0
    for i in range(n):
        wait += w[i]
        wsum -= w[i]
        if wait > p:
            k -= 1
            wait = w[i]
            if k == 0 or p < wsum / k:
                return False
    return True loadable pre_f = p p pre_f p = math.ceil(p * 1.01) math.ceil(p * 1.01) p
import math, sys

def loadable(w, n, k, p, wsum):
    wait = 0
    for i in range(n):
        wait += w[i]
        wsum -= w[i]
        if wait > p:
            k -= 1
            wait = w[i]
            if k == 0 or p < wsum / k:
                return False
    return True

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

wsum = sum(w)

p = max(int(math.ceil(wsum / k)), max(w))
pre_f = p -1
pre_s = None

while True:
    if loadable(w, n, k, p, wsum):
        pre_s = p
    else:
        pre_f = p

    if pre_s != None and pre_s - pre_f == 1:
            break
    
    if pre_s:
        p = int((pre_s + pre_f) / 2)
    else:
        p = math.ceil(p * 1.01)
    
print(pre_s)