def track(A, n, k, P): # 最大積載量Pを決めた時，何個の荷物を載せることができるかを返す
	i = 0
	for _ in range(k):
		weight_of_track_j = 0
		while weight_of_track_j + A[i] <= P:
			weight_of_track_j += A[i]
			i += 1
			if i == n:
				return n
	return i


if __name__ == "__main__":
	n, k = map(int, input().split())
	w = []
	for _ in range(n):
		w.append(int(input()))
	left = 0
	right = 100000 * 10000 # トラックの数 * 荷物の最大重み
	key = n
	while right - left > 1:
		mid = (left + right) // 2
		if key > track(w, n, k, mid):
			left = mid
		else:
			right = mid
	print(right)
 def track(A, n, k, P): # 最大積載量Pを決めた時，何個の荷物を載せることができるかを返す
	i = 0
	for _ in range(k):
		weight_of_track_j = 0
		while weight_of_track_j + A[i] <= P:
			weight_of_track_j += A[i]
			i += 1
			if i == n:
				return n
	return i track i = 0 i 0 for _ in range(k):
		weight_of_track_j = 0
		while weight_of_track_j + A[i] <= P:
			weight_of_track_j += A[i]
			i += 1
			if i == n:
				return n
	 _ range(k) range k weight_of_track_j = 0 weight_of_track_j 0 while weight_of_track_j + A[i] <= P:
			weight_of_track_j += A[i]
			i += 1
			if i == n:
				return n
	 weight_of_track_j + A[i] <= P weight_of_track_j + A[i] weight_of_track_j A[i] A i P weight_of_track_j += A[i] weight_of_track_j A[i] A i i += 1 i 1 if i == n:
				return n
	 i == n i n return n n return i i A A n n k k P P if __name__ == "__main__":
	n, k = map(int, input().split())
	w = []
	for _ in range(n):
		w.append(int(input()))
	left = 0
	right = 100000 * 10000 # トラックの数 * 荷物の最大重み
	key = n
	while right - left > 1:
		mid = (left + right) // 2
		if key > track(w, n, k, mid):
			left = mid
		else:
			right = mid
	print(right) __name__ == "__main__" __name__ "__main__" n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k w = [] w [] for _ in range(n):
		w.append(int(input()))
	 _ range(n) range n w.append(int(input())) w.append w append int(input()) int input() input left = 0 left 0 right = 100000 * 10000 right 100000 * 10000 100000 10000 key = n key n while right - left > 1:
		mid = (left + right) // 2
		if key > track(w, n, k, mid):
			left = mid
		else:
			right = mid
	 right - left > 1 right - left right left 1 mid = (left + right) // 2 mid (left + right) // 2 left + right left right 2 if key > track(w, n, k, mid):
			left = mid
		else:
			right = mid
	 key > track(w, n, k, mid) key track(w, n, k, mid) track w n k mid left = mid left mid right = mid right mid print(right) print right k = map(int, input().split()) map(int, input().split()) k left = mid mid left right = 100000 * 10000 100000 * 10000 right w = [] [] w left = 0 0 left key = n n key mid = (left + right) // 2 (left + right) // 2 mid right = mid mid right def track(A, n, k, P): # 最大積載量Pを決めた時，何個の荷物を載せることができるかを返す
	i = 0
	for _ in range(k):
		weight_of_track_j = 0
		while weight_of_track_j + A[i] <= P:
			weight_of_track_j += A[i]
			i += 1
			if i == n:
				return n
	return i def track(A, n, k, P): # 最大積載量Pを決めた時，何個の荷物を載せることができるかを返す
	i = 0
	for _ in range(k):
		weight_of_track_j = 0
		while weight_of_track_j + A[i] <= P:
			weight_of_track_j += A[i]
			i += 1
			if i == n:
				return n
	return i track n, k = map(int, input().split()) map(int, input().split()) n
def track(A, n, k, P): # 最大積載量Pを決めた時，何個の荷物を載せることができるかを返す
	i = 0
	for _ in range(k):
		weight_of_track_j = 0
		while weight_of_track_j + A[i] <= P:
			weight_of_track_j += A[i]
			i += 1
			if i == n:
				return n
	return i


if __name__ == "__main__":
	n, k = map(int, input().split())
	w = []
	for _ in range(n):
		w.append(int(input()))
	left = 0
	right = 100000 * 10000 # トラックの数 * 荷物の最大重み
	key = n
	while right - left > 1:
		mid = (left + right) // 2
		if key > track(w, n, k, mid):
			left = mid
		else:
			right = mid
	print(right)

