n,k = map(int,input().split())
w = []
for i in range(n):
	w.append(int(input()))
s = sum(w)
m = max(w) - 1
while (s-m) > 1:
	mid = (s+m+1)//2
	tmp = 0
	c = 0	
	for i in w:
		if tmp+i > mid:
			tmp = i
			c += 1
		else:
			tmp += i
	if c < k:
		s = mid
	else:
		m = mid
print(s) 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 s = sum(w) s sum(w) sum w m = max(w) - 1 m max(w) - 1 max(w) max w 1 while (s-m) > 1:
	mid = (s+m+1)//2
	tmp = 0
	c = 0	
	for i in w:
		if tmp+i > mid:
			tmp = i
			c += 1
		else:
			tmp += i
	if c < k:
		s = mid
	else:
		m = mid (s-m) > 1 s-m s m 1 mid = (s+m+1)//2 mid (s+m+1)//2 s+m+1 s+m s m 1 2 tmp = 0 tmp 0 c = 0 c 0 for i in w:
		if tmp+i > mid:
			tmp = i
			c += 1
		else:
			tmp += i
	 i w if tmp+i > mid:
			tmp = i
			c += 1
		else:
			tmp += i
	 tmp+i > mid tmp+i tmp i mid tmp = i tmp i c += 1 c 1 tmp += i tmp i if c < k:
		s = mid
	else:
		m = mid c < k c k s = mid s mid m = mid m mid print(s) print s w = [] [] w tmp = 0 0 tmp c += 1 1 c s = mid mid s s = sum(w) sum(w) s n,k = map(int,input().split()) map(int,input().split()) n mid = (s+m+1)//2 (s+m+1)//2 mid m = mid mid m k = map(int,input().split()) map(int,input().split()) k tmp += i i tmp c = 0 0 c m = max(w) - 1 max(w) - 1 m tmp = i i tmp
n,k = map(int,input().split())
w = []
for i in range(n):
	w.append(int(input()))
s = sum(w)
m = max(w) - 1
while (s-m) > 1:
	mid = (s+m+1)//2
	tmp = 0
	c = 0	
	for i in w:
		if tmp+i > mid:
			tmp = i
			c += 1
		else:
			tmp += i
	if c < k:
		s = mid
	else:
		m = mid
print(s)
