import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn :: IO Int
    ls <- fmap read . words <$> getLine :: IO [Int]
    let go [] = 0
        go (a:b:bs) = min a b + go bs
    print $ go (sort ls)