n,k = gets.chomp.split(" ").map(&:to_i)

sum = 0
w = Array.new
n.times { |i|
	w[i] = gets.chomp.to_i
	sum += w[i]
}
max_size = w.max

min = nil
if k == 1
	min = sum
elsif n == k
	min = max_size
else
	left = max_size
	right = sum
	
	while left <= right
		mid = ((left + right) / 2).to_i
		
		truck = 0
		cnt = 0
		w.each { |i|
			if truck + i <= mid
				truck += i
			else
				cnt += 1
				truck = i
				if cnt >= k
					break
				end
			end
		}
		
		if cnt >= k
			left = mid + 1
		else
			right = mid - 1
			min = mid
		end
	end
end

puts min