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

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


def solve():
	r = 1000000000
	l = 0
	while r-l > 1:
		mid = int((r+l)/2)
		v = check(mid)
		if(v >= n):
			r = mid
		else:
			l = mid
	return r

print(solve()) n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k w = [] w [] for i in range(0,n):
	w.append(int(input())) i range(0,n) range 0 n w.append(int(input())) w.append w append int(input()) int input() input def check(p):
	i = 0
	for j in range(0,k):
		sm = 0
		while sm + w[i] <= p:
			sm = sm + w[i]
			i = i + 1
			if i == n:
				return n
	return i check i = 0 i 0 for j in range(0,k):
		sm = 0
		while sm + w[i] <= p:
			sm = sm + w[i]
			i = i + 1
			if i == n:
				return n
	 j range(0,k) range 0 k sm = 0 sm 0 while sm + w[i] <= p:
			sm = sm + w[i]
			i = i + 1
			if i == n:
				return n
	 sm + w[i] <= p sm + w[i] sm w[i] w i p sm = sm + w[i] sm sm + w[i] sm w[i] w i i = i + 1 i i + 1 i 1 if i == n:
				return n
	 i == n i n return n n return i i p p def solve():
	r = 1000000000
	l = 0
	while r-l > 1:
		mid = int((r+l)/2)
		v = check(mid)
		if(v >= n):
			r = mid
		else:
			l = mid
	return r solve r = 1000000000 r 1000000000 l = 0 l 0 while r-l > 1:
		mid = int((r+l)/2)
		v = check(mid)
		if(v >= n):
			r = mid
		else:
			l = mid
	 r-l > 1 r-l r l 1 mid = int((r+l)/2) mid int((r+l)/2) int (r+l)/2 r+l r l 2 v = check(mid) v check(mid) check mid if(v >= n):
			r = mid
		else:
			l = mid
	 v >= n v n r = mid r mid l = mid l mid return r r print(solve()) print solve() solve n,k = map(int,input().split()) map(int,input().split()) n k = map(int,input().split()) map(int,input().split()) k def check(p):
	i = 0
	for j in range(0,k):
		sm = 0
		while sm + w[i] <= p:
			sm = sm + w[i]
			i = i + 1
			if i == n:
				return n
	return i def check(p):
	i = 0
	for j in range(0,k):
		sm = 0
		while sm + w[i] <= p:
			sm = sm + w[i]
			i = i + 1
			if i == n:
				return n
	return i check w = [] [] w def solve():
	r = 1000000000
	l = 0
	while r-l > 1:
		mid = int((r+l)/2)
		v = check(mid)
		if(v >= n):
			r = mid
		else:
			l = mid
	return r def solve():
	r = 1000000000
	l = 0
	while r-l > 1:
		mid = int((r+l)/2)
		v = check(mid)
		if(v >= n):
			r = mid
		else:
			l = mid
	return r solve
n,k = map(int,input().split())
w = []
for i in range(0,n):
	w.append(int(input()))

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


def solve():
	r = 1000000000
	l = 0
	while r-l > 1:
		mid = int((r+l)/2)
		v = check(mid)
		if(v >= n):
			r = mid
		else:
			l = mid
	return r

print(solve())
