
def count_necessary_num_of_track(baggages, capacity)
  num_of_track = 1
  baggage_index = 0
  loaded_weight = 0
  num_of_baggage = baggages.count
  while baggage_index < num_of_baggage
    loaded_weight += baggages[baggage_index]
    if loaded_weight > capacity
      num_of_track += 1
      loaded_weight = 0
      next
    else
      baggage_index += 1
    end
  end
  return num_of_track
end


def calc_minimum_capacity(max_weight, baggages, k)
  candidates_for_capacity = (max_weight..10000*100000).to_a #?????§????????????*?????§???????????°=?????§????????????
  return candidates_for_capacity.bsearch{|candidate_for_capacity|
    count_necessary_num_of_track(baggages, candidate_for_capacity) <= k}
end

n, k = gets.chomp.split.map(&:to_i)
baggages = Array.new
n.times do
  baggages.push(gets.chomp.to_i)
end
max_weight = baggages.max
puts calc_minimum_capacity(max_weight, baggages, k)