import sys
input = lambda: sys.stdin.readline()[:-1]
n,k=map(int,input().split())
w = [int(input()) for i in range(n)][::-1]
def maxnumber(p): 
	wc=w.copy()
	for i in range(k):
		lim=p
		while len(wc):
			if wc[-1]<=lim:
				lim-=wc.pop()
			else:break
	return len(wc)

minp=float('inf')
left,right=1,10**9+1
while left<right:
	mid=(left+right)//2
	maxn=maxnumber(mid)
	if maxn>0:
		left=mid+1
	else:
		right=mid
		minp=min(mid,minp)
print(minp)






	
 import sys sys input = lambda: sys.stdin.readline()[:-1] input lambda: sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 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)][::-1] w [int(input()) for i in range(n)][::-1] [int(input()) for i in range(n)] ::-1 -1 def maxnumber(p): 
	wc=w.copy()
	for i in range(k):
		lim=p
		while len(wc):
			if wc[-1]<=lim:
				lim-=wc.pop()
			else:break
	return len(wc) maxnumber wc=w.copy() wc w.copy() w.copy w copy for i in range(k):
		lim=p
		while len(wc):
			if wc[-1]<=lim:
				lim-=wc.pop()
			else:break
	 i range(k) range k lim=p lim p while len(wc):
			if wc[-1]<=lim:
				lim-=wc.pop()
			else:break
	 len(wc) len wc if wc[-1]<=lim:
				lim-=wc.pop()
			else:break
	 wc[-1]<=lim wc[-1] wc -1 lim lim-=wc.pop() lim wc.pop() wc.pop wc pop return len(wc) len(wc) len wc p p minp=float('inf') minp float('inf') float 'inf' left,right=1,10**9+1 left 1 right 10**9+1 10**9 10 9 1 while left<right:
	mid=(left+right)//2
	maxn=maxnumber(mid)
	if maxn>0:
		left=mid+1
	else:
		right=mid
		minp=min(mid,minp) left<right left right mid=(left+right)//2 mid (left+right)//2 left+right left right 2 maxn=maxnumber(mid) maxn maxnumber(mid) maxnumber mid if maxn>0:
		left=mid+1
	else:
		right=mid
		minp=min(mid,minp) maxn>0 maxn 0 left=mid+1 left mid+1 mid 1 right=mid right mid minp=min(mid,minp) minp min(mid,minp) min mid minp print(minp) print minp mid=(left+right)//2 (left+right)//2 mid left,right=1,10**9+1 1 left minp=min(mid,minp) min(mid,minp) minp def maxnumber(p): 
	wc=w.copy()
	for i in range(k):
		lim=p
		while len(wc):
			if wc[-1]<=lim:
				lim-=wc.pop()
			else:break
	return len(wc) def maxnumber(p): 
	wc=w.copy()
	for i in range(k):
		lim=p
		while len(wc):
			if wc[-1]<=lim:
				lim-=wc.pop()
			else:break
	return len(wc) maxnumber w = [int(input()) for i in range(n)][::-1] [int(input()) for i in range(n)][::-1] w left=mid+1 mid+1 left right=1,10**9+1 10**9+1 right right=mid mid right input = lambda: sys.stdin.readline()[:-1] lambda: sys.stdin.readline()[:-1] input maxn=maxnumber(mid) maxnumber(mid) maxn minp=float('inf') float('inf') minp k=map(int,input().split()) map(int,input().split()) k n,k=map(int,input().split()) map(int,input().split()) n
import sys
input = lambda: sys.stdin.readline()[:-1]
n,k=map(int,input().split())
w = [int(input()) for i in range(n)][::-1]
def maxnumber(p): 
	wc=w.copy()
	for i in range(k):
		lim=p
		while len(wc):
			if wc[-1]<=lim:
				lim-=wc.pop()
			else:break
	return len(wc)

minp=float('inf')
left,right=1,10**9+1
while left<right:
	mid=(left+right)//2
	maxn=maxnumber(mid)
	if maxn>0:
		left=mid+1
	else:
		right=mid
		minp=min(mid,minp)
print(minp)






	

