n, k = gets.split( " " ).map { |val| val.to_i }
w = []
maxW = sumW = 0
n.times {
	num = gets.to_i
	sumW += num
	w.push( num )
}
maxW = w.max

minP = 0
if 1 == k
	minP = sumW
elsif n == k
	minP = maxW
else
	left = maxW
	right = 100000*10000
	while left <= right
		middle = ( left+right ).div( 2 )
		truckCnt = i = loadings = 0

		while i < n
			loadings += w[i]
			if middle < loadings
				truckCnt += 1
				break if k < truckCnt+1
				loadings = w[i]
			end
			i += 1
		end
		( minP = middle ) if truckCnt+1 <= k
		
		if k < truckCnt+1
			left = middle + 1		
		else
			right = middle - 1
		end
	end
end

puts( minP )