n, k = map(int, raw_input().split())
w = []
max = 0
sum = 0
for i in xrange(n):
	w_i = int(raw_input())
	if w_i > max:
		max = w_i
	sum += w_i
	w.append(w_i)

def can_put(w, p, k):
	weight = 0
	cnt = 1
	for w_i in w:
		if weight + w_i <= p:
			weight += w_i
		else:
			cnt += 1
			if cnt > k:
				return 0
			else:
				weight = w_i
	return 1

low = max
high = sum

while low < high:
	mid = (low + high) / 2
	#print high, mid, low
	if can_put(w, mid, k) == 1:
		#print("*1")
		high = mid
	else:
		#print("*0")
		low = mid + 1
	#print high, mid, low
print high n, k = map(int, raw_input().split()) n map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split k w = [] w [] max = 0 max 0 sum = 0 sum 0 for i in xrange(n):
	w_i = int(raw_input())
	if w_i > max:
		max = w_i
	sum += w_i
	w.append(w_i) i xrange(n) xrange n w_i = int(raw_input()) w_i int(raw_input()) int raw_input() raw_input if w_i > max:
		max = w_i
	 w_i > max w_i max max = w_i max w_i sum += w_i sum w_i w.append(w_i) w.append w append w_i def can_put(w, p, k):
	weight = 0
	cnt = 1
	for w_i in w:
		if weight + w_i <= p:
			weight += w_i
		else:
			cnt += 1
			if cnt > k:
				return 0
			else:
				weight = w_i
	return 1 can_put weight = 0 weight 0 cnt = 1 cnt 1 for w_i in w:
		if weight + w_i <= p:
			weight += w_i
		else:
			cnt += 1
			if cnt > k:
				return 0
			else:
				weight = w_i
	 w_i w if weight + w_i <= p:
			weight += w_i
		else:
			cnt += 1
			if cnt > k:
				return 0
			else:
				weight = w_i
	 weight + w_i <= p weight + w_i weight w_i p weight += w_i weight w_i cnt += 1 cnt 1 if cnt > k:
				return 0
			else:
				weight = w_i
	 cnt > k cnt k return 0 0 weight = w_i weight w_i return 1 1 w w p p k k low = max low max high = sum high sum while low < high:
	mid = (low + high) / 2
	#print high, mid, low
	if can_put(w, mid, k) == 1:
		#print("*1")
		high = mid
	else:
		#print("*0")
		low = mid + 1
	#print high, mid, low low < high low high mid = (low + high) / 2 mid (low + high) / 2 low + high low high 2 if can_put(w, mid, k) == 1:
		#print("*1")
		high = mid
	else:
		#print("*0")
		low = mid + 1
	#print high, mid, low can_put(w, mid, k) == 1 can_put(w, mid, k) can_put w mid k 1 high = mid high mid low = mid + 1 low mid + 1 mid 1 print sum += w_i w_i sum high = sum sum high w_i = int(raw_input()) int(raw_input()) w_i def can_put(w, p, k):
	weight = 0
	cnt = 1
	for w_i in w:
		if weight + w_i <= p:
			weight += w_i
		else:
			cnt += 1
			if cnt > k:
				return 0
			else:
				weight = w_i
	return 1 def can_put(w, p, k):
	weight = 0
	cnt = 1
	for w_i in w:
		if weight + w_i <= p:
			weight += w_i
		else:
			cnt += 1
			if cnt > k:
				return 0
			else:
				weight = w_i
	return 1 can_put sum = 0 0 sum high = mid mid high low = mid + 1 mid + 1 low n, k = map(int, raw_input().split()) map(int, raw_input().split()) n max = w_i w_i max low = max max low max = 0 0 max mid = (low + high) / 2 (low + high) / 2 mid w = [] [] w k = map(int, raw_input().split()) map(int, raw_input().split()) k
n, k = map(int, raw_input().split())
w = []
max = 0
sum = 0
for i in xrange(n):
	w_i = int(raw_input())
	if w_i > max:
		max = w_i
	sum += w_i
	w.append(w_i)

def can_put(w, p, k):
	weight = 0
	cnt = 1
	for w_i in w:
		if weight + w_i <= p:
			weight += w_i
		else:
			cnt += 1
			if cnt > k:
				return 0
			else:
				weight = w_i
	return 1

low = max
high = sum

while low < high:
	mid = (low + high) / 2
	#print high, mid, low
	if can_put(w, mid, k) == 1:
		#print("*1")
		high = mid
	else:
		#print("*0")
		low = mid + 1
	#print high, mid, low
print high