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
  | q == 0 = amax + 2 * sum (take p as1)
  | True   = amax + 2 * sum (take p as1) + as1 !! p
  where
    (amax:as1) = sortBy (flip compare) as
    (p,q) = divMod (n-2) 2