n, m = gets.split.map(&:to_i)
powers = gets.split.map(&:to_i).sort.reverse
# p powers
res = 0
rest_time = m
powers.each_with_index do |power, idx|
  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
  break if rest_time <= 0
end

puts res