import Data.List

main=do
    n <- getLine
    xs <- words <$> getLine
    print $ ans (read n :: Int) (sort (map (read::String -> Int) xs))

ans n xs = sum $ take (n-1) (kurik 0 (reverse xs))

kurik x xs = (xs !! div (x+1) 2):(kurik (x+1) xs)