import Control.Monad
main = do
        a <- readLn ; b <- sort $ map read.word <$> getLine :: IO Int []
        let c <- [ b !! i | i <- [0,2..( length b - 1 )] ]
        let d <- foldl (+) b
        putStrLn $ 2 * c - d