n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]
s = max(w)-1
w.append(10**13)
t = sum(w)

while s+1 < t:
	m = (s + t) // 2
	x = 0
	c = 0
	for i in range(n+1):
		c += w[i]
		if c > m:
			x += 1
			c = w[i]
		elif c == m:
			if i != n-1:
				x += 1
				c = 0
	if x > k:
		s = m
	else:
		t = m

print(t) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input w = [int(input()) for _ in range(n)] w [int(input()) for _ in range(n)] s = max(w)-1 s max(w)-1 max(w) max w 1 w.append(10**13) w.append w append 10**13 10 13 t = sum(w) t sum(w) sum w while s+1 < t:
	m = (s + t) // 2
	x = 0
	c = 0
	for i in range(n+1):
		c += w[i]
		if c > m:
			x += 1
			c = w[i]
		elif c == m:
			if i != n-1:
				x += 1
				c = 0
	if x > k:
		s = m
	else:
		t = m s+1 < t s+1 s 1 t m = (s + t) // 2 m (s + t) // 2 s + t s t 2 x = 0 x 0 c = 0 c 0 for i in range(n+1):
		c += w[i]
		if c > m:
			x += 1
			c = w[i]
		elif c == m:
			if i != n-1:
				x += 1
				c = 0
	 i range(n+1) range n+1 n 1 c += w[i] c w[i] w i if c > m:
			x += 1
			c = w[i]
		elif c == m:
			if i != n-1:
				x += 1
				c = 0
	 c > m c m x += 1 x 1 c = w[i] c w[i] w i elif c == m:
			if i != n-1:
				x += 1
				c = 0
	 c == m c m if i != n-1:
				x += 1
				c = 0
	 i != n-1 i n-1 n 1 x += 1 x 1 c = 0 c 0 if x > k:
		s = m
	else:
		t = m x > k x k s = m s m t = m t m print(t) print t m = (s + t) // 2 (s + t) // 2 m c += w[i] w[i] c t = m m t x += 1 1 x n, k = map(int, input().split()) map(int, input().split()) n x = 0 0 x x += 1 1 x k = map(int, input().split()) map(int, input().split()) k s = m m s c = 0 0 c c = w[i] w[i] c s = max(w)-1 max(w)-1 s c = 0 0 c w = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] w t = sum(w) sum(w) t
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]
s = max(w)-1
w.append(10**13)
t = sum(w)

while s+1 < t:
	m = (s + t) // 2
	x = 0
	c = 0
	for i in range(n+1):
		c += w[i]
		if c > m:
			x += 1
			c = w[i]
		elif c == m:
			if i != n-1:
				x += 1
				c = 0
	if x > k:
		s = m
	else:
		t = m

print(t)
