$truck_number = 0
class Truck
  def initialize
    @weight = 0
    $truck_number += 1
  end
  attr_accessor :max_weight, :truck_number

  def put(weight)
    @weight += weight
  end
end

n, k = gets.split(' ').map(&:to_i)
packages = []
sum = 0
n.times do
  packages << gets.to_i
end
average_weight_per_truck = (packages.sum / k)..(packages.sum / k) + 2
truck = Truck.new
min_max_weight = 0
packages.each do |value|
  sum += value
  if average_weight_per_truck === sum
    min_max_weight = sum if min_max_weight < sum
    truck = Truck.new
    sum = 0
  end
  break if $truck_number > k
  truck.put value
end

puts min_max_weight
