import Control.Applicative
import Data.List

solve [] = 0
solve (x:y:xs) = min x y + solve xs

main :: IO()
main = do
	getLine
	l <- sort . map (read::String->Int) . words <$> getLine
	print $ solve l