n, k = gets.split.map(&:to_i)
weights = 1.upto(n).map{gets.to_i}
max = weights.max

def count_truck(weights, max_payload, k)
  payload = 0
  truck_counter = 1
  for w in weights do
    next_payload = payload + w
    if next_payload > max_payload
      payload = w
      truck_counter += 1
      break if truck_counter > k
    else
      payload = next_payload
    end
  end
  truck_counter
end

puts (max..1000000000).bsearch{|p| count_truck(weights, p, k) <= k}