$num,$tracks = gets.split.map(&:to_i)
$ws = []
for i in 1..$num do
	w = gets.chomp.to_i
	$ws.push(w)
end

def check(p)
	i = 0
	for j in 1..$tracks do
		s = 0
		while s + $ws[i] <= p
			s = s + $ws[i]
			i = i + 1
			if i == $num then
				return $num
			end
		end
	end
	return i
end

def solve()
	left = 0
	right = 100000 * 10000
	while right - left > 1
		mid = (left + right) / 2
		v = check(mid)
		if v >= $num then
			right = mid
		else
			left = mid
		end
	end
	return right
end

ans = solve()
p ans