import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B

main=do
    n<-readLn
    as<-sortBy(flip compare).unfoldr(B.readInt.B.dropWhile(==' '))<$>B.getLine
    print$sol 0 n as
sol c 0 _ = c
sol c n (a:b:r) = sol (c+b) (n-1) r