import Data.List

main = do
  n <- map(read::[Char]->Int) <$> words <$> getLine
  l <- sort <$> map(read::[Char]->Int) <$> words <$> getLine
  print $ abc l

abc::[Int]->Int
abc [] = 0
abc (x:y:xs) = min x y + abc xs