n,k=map(int,input().split())
l=0
r=10**9+1
ww=[]
for i in range(n):
	ww.append(int(input()))
while l<r:
	mid=(r+l)//2
	cnt=0
	tr=1
	for i in range(n):
		w=ww[i]
		if w>mid or tr>k:
			tr=10**18
			l=mid+1
			break
		if w+cnt<=mid:
			cnt+=w
		else:
			cnt=w
			tr+=1
	if tr<=k:
		r=mid
	else:
		l=mid+1
print(l)

	
 n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k l=0 l 0 r=10**9+1 r 10**9+1 10**9 10 9 1 ww=[] ww [] for i in range(n):
	ww.append(int(input())) i range(n) range n ww.append(int(input())) ww.append ww append int(input()) int input() input while l<r:
	mid=(r+l)//2
	cnt=0
	tr=1
	for i in range(n):
		w=ww[i]
		if w>mid or tr>k:
			tr=10**18
			l=mid+1
			break
		if w+cnt<=mid:
			cnt+=w
		else:
			cnt=w
			tr+=1
	if tr<=k:
		r=mid
	else:
		l=mid+1 l<r l r mid=(r+l)//2 mid (r+l)//2 r+l r l 2 cnt=0 cnt 0 tr=1 tr 1 for i in range(n):
		w=ww[i]
		if w>mid or tr>k:
			tr=10**18
			l=mid+1
			break
		if w+cnt<=mid:
			cnt+=w
		else:
			cnt=w
			tr+=1
	 i range(n) range n w=ww[i] w ww[i] ww i if w>mid or tr>k:
			tr=10**18
			l=mid+1
			break
		 w>mid or tr>k w>mid w mid tr>k tr k tr=10**18 tr 10**18 10 18 l=mid+1 l mid+1 mid 1 break if w+cnt<=mid:
			cnt+=w
		else:
			cnt=w
			tr+=1
	 w+cnt<=mid w+cnt w cnt mid cnt+=w cnt w cnt=w cnt w tr+=1 tr 1 if tr<=k:
		r=mid
	else:
		l=mid+1 tr<=k tr k r=mid r mid l=mid+1 l mid+1 mid 1 print(l) print l tr+=1 1 tr n,k=map(int,input().split()) map(int,input().split()) n cnt+=w w cnt mid=(r+l)//2 (r+l)//2 mid k=map(int,input().split()) map(int,input().split()) k r=10**9+1 10**9+1 r l=mid+1 mid+1 l tr=1 1 tr ww=[] [] ww cnt=w w cnt w=ww[i] ww[i] w l=mid+1 mid+1 l cnt=0 0 cnt l=0 0 l r=mid mid r tr=10**18 10**18 tr
n,k=map(int,input().split())
l=0
r=10**9+1
ww=[]
for i in range(n):
	ww.append(int(input()))
while l<r:
	mid=(r+l)//2
	cnt=0
	tr=1
	for i in range(n):
		w=ww[i]
		if w>mid or tr>k:
			tr=10**18
			l=mid+1
			break
		if w+cnt<=mid:
			cnt+=w
		else:
			cnt=w
			tr+=1
	if tr<=k:
		r=mid
	else:
		l=mid+1
print(l)

	

