n, m = gets.split.map(&:to_i)
powers = gets.split.map(&:to_i).sort.reverse
# p powers
res = 0

shake_powers = []

powers.each { |i| shake_powers << i * 2 }

powers.combination(2) do |l, r|
  2.times { shake_powers << l + r }
end
shake_powers.sort!.reverse!
puts shake_powers[0..m-1].inject(:+)

# rest_time = m

# powers.each_with_index do |power, idx|
#   break if rest_time <= 0
#   idx.upto(n - 1) do |inner_idx|
#     res += power + powers[inner_idx]
#     # p [rest_time, power, powers[inner_idx], res]
#     rest_time -= 1
#     break if rest_time <= 0

#     next if idx == inner_idx
#     res += power + powers[inner_idx]
#     # p [rest_time, power, powers[inner_idx], res]
#     rest_time -= 1
#     break if rest_time <= 0

#   end
# end

# puts res