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