class TrackManager
	
	def initialize(num_of_tracks, baggages)
		@tracks = Array.new(num_of_tracks, 0)
		@baggages = baggages.sort { |a, b| -(a <=> b) }
		@min_loaded_index = 0
	end

	def optimize_capacity
		until @baggages.empty?
			@tracks[@min_loaded_index] += @baggages.shift
			@min_loaded_index = compute_min_loaded_index
		end
		@tracks.max
	end

	private
	def compute_min_loaded_index
		min_index = 0
		(1...@tracks.size).each do |i|
			if @tracks[i] < @tracks[min_index]
				min_index = i
			end
			return min_index if @tracks[min_index] == 0
		end
		min_index
	end

end


num_of_baggages, num_of_tracks = STDIN.gets.split[0...2].map(&:to_i)
baggages = []
num_of_baggages.times { baggages << STDIN.gets.to_i }
puts TrackManager.new(num_of_tracks, baggages).optimize_capacity