n,k = map(int,raw_input().split())
weights = []
for i in range(n):
	weights.append(int(input()))

def check(p):
	i = 0
	for j in range(k):
		w = 0
		while w + weights[i] < p:
			w += weights[i]
			i += 1
			if i == n:
				return True

	return False

left = 0
right = 100000 * 10000
mid = 0

while right - left > 1 :
	mid = (left + right)/2
	if check(mid):
		right = mid
	else : 
		left = mid

print right-1

 n,k = map(int,raw_input().split()) n map(int,raw_input().split()) map int raw_input().split() ().split () raw_input split k weights = [] weights [] for i in range(n):
	weights.append(int(input())) i range(n) range n weights.append(int(input())) weights.append weights append int(input()) int input() input def check(p):
	i = 0
	for j in range(k):
		w = 0
		while w + weights[i] < p:
			w += weights[i]
			i += 1
			if i == n:
				return True

	return False check i = 0 i 0 for j in range(k):
		w = 0
		while w + weights[i] < p:
			w += weights[i]
			i += 1
			if i == n:
				return True

	 j range(k) range k w = 0 w 0 while w + weights[i] < p:
			w += weights[i]
			i += 1
			if i == n:
				return True

	 w + weights[i] < p w + weights[i] w weights[i] weights i p w += weights[i] w weights[i] weights i i += 1 i 1 if i == n:
				return True

	 i == n i n return True True return False False p p left = 0 left 0 right = 100000 * 10000 right 100000 * 10000 100000 10000 mid = 0 mid 0 while right - left > 1 :
	mid = (left + right)/2
	if check(mid):
		right = mid
	else : 
		left = mid right - left > 1 right - left right left 1 mid = (left + right)/2 mid (left + right)/2 left + right left right 2 if check(mid):
		right = mid
	else : 
		left = mid check(mid) check mid right = mid right mid left = mid left mid print right-1 right 1 mid = (left + right)/2 (left + right)/2 mid right = mid mid right weights = [] [] weights left = 0 0 left k = map(int,raw_input().split()) map(int,raw_input().split()) k left = mid mid left n,k = map(int,raw_input().split()) map(int,raw_input().split()) n def check(p):
	i = 0
	for j in range(k):
		w = 0
		while w + weights[i] < p:
			w += weights[i]
			i += 1
			if i == n:
				return True

	return False def check(p):
	i = 0
	for j in range(k):
		w = 0
		while w + weights[i] < p:
			w += weights[i]
			i += 1
			if i == n:
				return True

	return False check right = 100000 * 10000 100000 * 10000 right mid = 0 0 mid
n,k = map(int,raw_input().split())
weights = []
for i in range(n):
	weights.append(int(input()))

def check(p):
	i = 0
	for j in range(k):
		w = 0
		while w + weights[i] < p:
			w += weights[i]
			i += 1
			if i == n:
				return True

	return False

left = 0
right = 100000 * 10000
mid = 0

while right - left > 1 :
	mid = (left + right)/2
	if check(mid):
		right = mid
	else : 
		left = mid

print right-1


