articipants_count, shake_count = gets.split.map(&:to_i)
powers = gets.split.map(&:to_i).sort.reverse

get_point = 0
shake_powers = []

powers.each do |p_l|
  powers.each do |p_r|
    shake_powers <<  p_l + p_r
  end
end

shake_powers = shake_powers.sort.reverse

(0..(shake_count-1)).each do |i|
  get_point += shake_powers[i]
end

puts get_point