module IOArray where
import qualified Data.Array.IO as A
import qualified Data.List as L
import Debug.Trace

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    ls <- L.reverse . L.sort . map read . words <$> getLine :: IO [Int]
    print (sum . pairs $ ls)

pairs :: [Int] -> [Int]
pairs [] = []
pairs (_:[]) = []
pairs (x:y:xs) = let
    in min x y : pairs xs

(!) :: (A.Ix x) => A.IOArray x y -> x -> IO y
arr ! n = A.readArray arr n
{-# INLINE (!) #-}
 
(!?) :: (A.Ix x) => A.IOArray x y -> x -> IO (Maybe y)
arr !? n = do
    (start, last) <- A.getBounds arr
    if n >= start && last >= n 
        then Just <$> A.readArray arr n 
        else return Nothing
{-# INLINE (!?) #-}
 
(<<-) :: (A.Ix x) => (A.IOArray x y, x) -> y -> IO ()
(arr, i) <<- v = A.writeArray arr i v
{-# INLINE (<<-) #-}
 