function rl()
   local r = {}
   for word in io.read():gmatch("%S+") do
      table.insert(r, tonumber(word))
   end
   return r
end

function ru()
   return unpack(rl())
end

function pu(x, ...)
   if x then
      io.write(x, ' ')
      return pu(...)
   else
      io.write('\n')
   end
end

N = ru()
A = rl()

table.sort(A)

r = -A[N]
t = 0
for i = N, 1, -1 do
   r = r + A[i]
   t = t + 1
   if t >= N then break end
   r = r + A[i]
   t = t + 1
   if t >= N then break end
end

pu(r)
