def check(P):

 i=0

 for _ in[0]*k:

  s=0

  while s+w[i]<=P:

   s+=w[i];i+=1

   if i==n: return n

 return i

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

w=[int(eval(input()))for _ in[0]*n]

l=0;r=n*100000

while r-l>1:

 m=(l+r)//2

 if check(m)>=n:r=m

 else:l=m

print(r)

import sys

def f(P):

 i=0

 for _ in[0]*k:

  s=0

  while s+w[i]<=P:

   s+=w[i];i+=1

   if i==n: return n

 return i

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

w=list(map(int,sys.stdin.read().splitlines()))

l=0;r=n*100000

while r-l>1:

 m=(l+r)//2

 if f(m)>=n:r=m

 else:l=m

print(r)

def check(P):
    i = 0
    for _ in [0] * k:
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if i == n:
                return n
    return i


n, k = list(map(int, input().split()))
w = [int(eval(input())) for _ in [0] * n]
l = 0
r = n * 100000
while r - l > 1:
    m = (l + r) // 2
    if check(m) >= n:
        r = m
    else:
        l = m
print(r)

import sys


def f(P):
    i = 0
    for _ in [0] * k:
        s = 0
        while s + w[i] <= P:
            s += w[i]
            i += 1
            if i == n:
                return n
    return i


n, k = list(map(int, input().split()))
w = list(map(int, sys.stdin.read().splitlines()))
l = 0
r = n * 100000
while r - l > 1:
    m = (l + r) // 2
    if f(m) >= n:
        r = m
    else:
        l = m
print(r)

-def check(P): +import sys + + +def f(P): -w = [int(eval(input())) for _ in [0] * n] +w = list(map(int, sys.stdin.read().splitlines())) -    if check(m) >= n: +    if f(m) >= n: