import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  li <- BS.getLine
  let Just (n,_) = BS.readInt li
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n as
  print ans

compute :: Int -> [Int] -> Int
compute n as = fst $ foldl' step (0,[amax]) as1
  where
    (amax:as1) = sortBy (flip compare) as

step (sc,a:as) v = (sc+a, as ++ [v,v])