local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
table.sort(a, function(x, y) return x > y end)
local ans = a[1]
for i = 2, n - 1 do
  local p = 1 + (i // 2)
  ans = ans + a[p]
end
print(ans)
