n,k = [int(s) for s in input().split()]
#n,k = [int(s) for s in data.pop().split()]
#n,k = 100000,100000
w_org = []
[w_org.append(int(input())) for i in range(n)]
#[w_org.append(int(data.pop())) for i in range(n)]
#w_org = [1 for i in range(n)]


def can(p_org,k):
	p = p_org
	w = w_org[::-1]
	while k and w:
		ww = w[-1]
		if ww <= p:
			p -= ww
			w.pop()
		else:
			p = p_org
			k -= 1
		if p == 0:
			p = p_org
			k -= 1
		#print(ww,k,p)
	return not(w)


left,right = max(w_org)-1,sum(w_org)+1
roop = 0
while left+1 < right:
	roop += 1
	middle = (left+right) // 2
	if can(middle,k):
		right = middle
	else:
		left = middle
print(right) int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s n,k = [int(s) for s in input().split()] n [int(s) for s in input().split()] k w_org = [] w_org [] w_org.append(int(input())) for i in range(n) for i in range(n) i range(n) range n for i in range(n) w_org.append(int(input())) w_org.append w_org append int(input()) int input() input [w_org.append(int(input())) for i in range(n)] def can(p_org,k):
	p = p_org
	w = w_org[::-1]
	while k and w:
		ww = w[-1]
		if ww <= p:
			p -= ww
			w.pop()
		else:
			p = p_org
			k -= 1
		if p == 0:
			p = p_org
			k -= 1
		#print(ww,k,p)
	return not(w) can p = p_org p p_org w = w_org[::-1] w w_org[::-1] w_org ::-1 -1 while k and w:
		ww = w[-1]
		if ww <= p:
			p -= ww
			w.pop()
		else:
			p = p_org
			k -= 1
		if p == 0:
			p = p_org
			k -= 1
		#print(ww,k,p)
	 k and w k w ww = w[-1] ww w[-1] w -1 if ww <= p:
			p -= ww
			w.pop()
		else:
			p = p_org
			k -= 1
		 ww <= p ww p p -= ww p ww w.pop() w.pop w pop p = p_org p p_org k -= 1 k 1 if p == 0:
			p = p_org
			k -= 1
		#print(ww,k,p)
	 p == 0 p 0 p = p_org p p_org k -= 1 k 1 return not(w) not(w) w p_org p_org k k left,right = max(w_org)-1,sum(w_org)+1 left max(w_org)-1 max(w_org) max w_org 1 right sum(w_org)+1 sum(w_org) sum w_org 1 roop = 0 roop 0 while left+1 < right:
	roop += 1
	middle = (left+right) // 2
	if can(middle,k):
		right = middle
	else:
		left = middle left+1 < right left+1 left 1 right roop += 1 roop 1 middle = (left+right) // 2 middle (left+right) // 2 left+right left right 2 if can(middle,k):
		right = middle
	else:
		left = middle can(middle,k) can middle k right = middle right middle left = middle left middle print(right) print right n,k = [int(s) for s in input().split()] [int(s) for s in input().split()] n w_org = [] [] w_org left,right = max(w_org)-1,sum(w_org)+1 max(w_org)-1 left k = [int(s) for s in input().split()] [int(s) for s in input().split()] k right = max(w_org)-1,sum(w_org)+1 sum(w_org)+1 right left = middle middle left right = middle middle right roop += 1 1 roop def can(p_org,k):
	p = p_org
	w = w_org[::-1]
	while k and w:
		ww = w[-1]
		if ww <= p:
			p -= ww
			w.pop()
		else:
			p = p_org
			k -= 1
		if p == 0:
			p = p_org
			k -= 1
		#print(ww,k,p)
	return not(w) def can(p_org,k):
	p = p_org
	w = w_org[::-1]
	while k and w:
		ww = w[-1]
		if ww <= p:
			p -= ww
			w.pop()
		else:
			p = p_org
			k -= 1
		if p == 0:
			p = p_org
			k -= 1
		#print(ww,k,p)
	return not(w) can middle = (left+right) // 2 (left+right) // 2 middle roop = 0 0 roop
n,k = [int(s) for s in input().split()]
#n,k = [int(s) for s in data.pop().split()]
#n,k = 100000,100000
w_org = []
[w_org.append(int(input())) for i in range(n)]
#[w_org.append(int(data.pop())) for i in range(n)]
#w_org = [1 for i in range(n)]


def can(p_org,k):
	p = p_org
	w = w_org[::-1]
	while k and w:
		ww = w[-1]
		if ww <= p:
			p -= ww
			w.pop()
		else:
			p = p_org
			k -= 1
		if p == 0:
			p = p_org
			k -= 1
		#print(ww,k,p)
	return not(w)


left,right = max(w_org)-1,sum(w_org)+1
roop = 0
while left+1 < right:
	roop += 1
	middle = (left+right) // 2
	if can(middle,k):
		right = middle
	else:
		left = middle
print(right)