#!/usr/bin/env ruby

n, k = gets.split.map(&:to_i)

baggages = []
trucks = []
k.times { trucks << 0 }
n.times { baggages << gets.to_i }

baggages.sort { |a, b| b <=> a }.each do |baggage|
  trucks << trucks.sort!.shift + baggage
end

puts trucks.max