import sys
import math 

def be_able_to_convey(w, k, p):
	counter = 0
	cur_weight = 0
	for wi in w:
		if wi > p:
			return False

		cur_weight += wi
		if(cur_weight > p):
			cur_weight = wi
			counter += 1
			if(counter >= k):
				return False

	return True

#fin = open("test.txt", "r")
fin = sys.stdin

n, k = map(int, fin.readline().split())
w = [0 for i in range(n)]

for i in range(n):
	w[i] = int(fin.readline())
	
pmin = 1
pmax = int(10e9)

while pmin < pmax:
	p = math.ceil((pmin + pmax) / 2)
	if p == pmin or p == pmax:
		if be_able_to_convey(w, k, pmin):
			p = pmin
		else:
			#if not be_able_to_convey(w, k, pmax):
			#	print("error")
			p = pmax
		break

	if not be_able_to_convey(w, k, p):
		pmin = p
	else:
		pmax = p

print(p) import sys sys import math math def be_able_to_convey(w, k, p):
	counter = 0
	cur_weight = 0
	for wi in w:
		if wi > p:
			return False

		cur_weight += wi
		if(cur_weight > p):
			cur_weight = wi
			counter += 1
			if(counter >= k):
				return False

	return True

#fin = open("test.txt", "r") be_able_to_convey counter = 0 counter 0 cur_weight = 0 cur_weight 0 for wi in w:
		if wi > p:
			return False

		cur_weight += wi
		if(cur_weight > p):
			cur_weight = wi
			counter += 1
			if(counter >= k):
				return False

	 wi w if wi > p:
			return False

		 wi > p wi p return False False cur_weight += wi cur_weight wi if(cur_weight > p):
			cur_weight = wi
			counter += 1
			if(counter >= k):
				return False

	 cur_weight > p cur_weight p cur_weight = wi cur_weight wi counter += 1 counter 1 if(counter >= k):
				return False

	 counter >= k counter k return False False return True True w w k k p p fin = sys.stdin fin sys.stdin sys stdin n, k = map(int, fin.readline().split()) n map(int, fin.readline().split()) map int fin.readline().split() fin.readline().split fin.readline() fin.readline fin readline split k 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 w = [0 for i in range(n)] w [0 for i in range(n)] for i in range(n):
	w[i] = int(fin.readline())
	 i range(n) range n w[i] = int(fin.readline()) w[i] w i int(fin.readline()) int fin.readline() fin.readline fin readline pmin = 1 pmin 1 pmax = int(10e9) pmax int(10e9) int 10e9 while pmin < pmax:
	p = math.ceil((pmin + pmax) / 2)
	if p == pmin or p == pmax:
		if be_able_to_convey(w, k, pmin):
			p = pmin
		else:
			#if not be_able_to_convey(w, k, pmax):
			#	print("error")
			p = pmax
		break

	if not be_able_to_convey(w, k, p):
		pmin = p
	else:
		pmax = p pmin < pmax pmin pmax p = math.ceil((pmin + pmax) / 2) p math.ceil((pmin + pmax) / 2) math.ceil math ceil (pmin + pmax) / 2 pmin + pmax pmin pmax 2 if p == pmin or p == pmax:
		if be_able_to_convey(w, k, pmin):
			p = pmin
		else:
			#if not be_able_to_convey(w, k, pmax):
			#	print("error")
			p = pmax
		break

	 p == pmin or p == pmax p == pmin p pmin p == pmax p pmax if be_able_to_convey(w, k, pmin):
			p = pmin
		else:
			#if not be_able_to_convey(w, k, pmax):
			#	print("error")
			p = pmax
		 be_able_to_convey(w, k, pmin) be_able_to_convey w k pmin p = pmin p pmin p = pmax p pmax break if not be_able_to_convey(w, k, p):
		pmin = p
	else:
		pmax = p not be_able_to_convey(w, k, p) be_able_to_convey(w, k, p) be_able_to_convey w k p pmin = p pmin p pmax = p pmax p print(p) print p def be_able_to_convey(w, k, p):
	counter = 0
	cur_weight = 0
	for wi in w:
		if wi > p:
			return False

		cur_weight += wi
		if(cur_weight > p):
			cur_weight = wi
			counter += 1
			if(counter >= k):
				return False

	return True

#fin = open("test.txt", "r") def be_able_to_convey(w, k, p):
	counter = 0
	cur_weight = 0
	for wi in w:
		if wi > p:
			return False

		cur_weight += wi
		if(cur_weight > p):
			cur_weight = wi
			counter += 1
			if(counter >= k):
				return False

	return True

#fin = open("test.txt", "r") be_able_to_convey p = pmax pmax p k = map(int, fin.readline().split()) map(int, fin.readline().split()) k pmax = p p pmax p = math.ceil((pmin + pmax) / 2) math.ceil((pmin + pmax) / 2) p fin = sys.stdin sys.stdin fin w = [0 for i in range(n)] [0 for i in range(n)] w pmin = 1 1 pmin pmax = int(10e9) int(10e9) pmax p = pmin pmin p pmin = p p pmin n, k = map(int, fin.readline().split()) map(int, fin.readline().split()) n
import sys
import math 

def be_able_to_convey(w, k, p):
	counter = 0
	cur_weight = 0
	for wi in w:
		if wi > p:
			return False

		cur_weight += wi
		if(cur_weight > p):
			cur_weight = wi
			counter += 1
			if(counter >= k):
				return False

	return True

#fin = open("test.txt", "r")
fin = sys.stdin

n, k = map(int, fin.readline().split())
w = [0 for i in range(n)]

for i in range(n):
	w[i] = int(fin.readline())
	
pmin = 1
pmax = int(10e9)

while pmin < pmax:
	p = math.ceil((pmin + pmax) / 2)
	if p == pmin or p == pmax:
		if be_able_to_convey(w, k, pmin):
			p = pmin
		else:
			#if not be_able_to_convey(w, k, pmax):
			#	print("error")
			p = pmax
		break

	if not be_able_to_convey(w, k, p):
		pmin = p
	else:
		pmax = p

print(p)