def calc_challenge(baggages, capacity)
  track_no = 1
  baggage_index = 0
  loaded = 0

  while (baggage_index < baggages.size) do
    loaded += baggages[baggage_index]
    if (loaded > capacity) then
      track_no += 1
      loaded = 0
    else
      baggage_index += 1
    end
  end

  return track_no
end

MAX_BAGGAGE_WEIGHT = 10000
MAX_BAGGAGE_NUM = 100000

n, k = gets.chomp.split.map(&:to_i)
baggages = []
(n).times do |i|
  baggages << gets.chomp.to_i
end

max_weight = baggages.max

puts (max_weight..(MAX_BAGGAGE_WEIGHT * MAX_BAGGAGE_NUM)).bsearch{|x|
  calc_challenge(baggages, x) <= k
}