def ship?(w, k, p)
  current_track = 0
  current_capacity = p
  w.each do |weight|
    while current_capacity < weight && current_track < k
      current_track += 1
      current_capacity = p
    end

    return false if current_track == k

    current_capacity -= weight
  end

  true
end

n, k = gets.split.map(&:to_i)
w = n.times.map{ gets.to_i }

p_min = w.max
p_max = w.inject(:+)
(p_min..p_max).each do |p|
  if ship?(w, k, p)
    puts p
    break
  end
end