N, M = gets.chomp.split(" ").map{|s| s.to_i}
A_ARR = gets.chomp.split(" ").map{|s| s.to_i}.sort_by{|n| -n}

arr = []
A_ARR.each_with_index do |n, i|
  A_ARR[i..-1].each_with_index do |m, j|
    arr << [n+m, m == 0 ? 1 : 2]
  end
end

arr.sort_by{|n, t| -n}

h = 0
count = 0
arr.each do |n, t|
  h += t * n
  count += t
  if M == count
    break
  elsif M == count - 1
    h -= n
    break
  end
end
puts h
