n, m = gets.strip.split.map { |v| v.to_i }
a = gets.strip.split.map { |v| v.to_i }

combination = []
a.each do |a_1|
  a.each do |a_2|
    combination.push(a_1 + a_2)
  end
end

puts combination.sort!.reverse!.take(m).inject(&:+)
