import Data.Ord

main :: IO ()
main = do
    _ <- getLine
    list <- map read . words <$> getLine
    let (alice, bob) = execGame (sortOn Down list) (0, 0)
    putStrLn $ show $ alice - bob 

execGame :: [Int] -> (Int, Int) -> (Int, Int)
execGame [] (a, b) = (a, b)
execGame [x] (a, b) = (a + x, b)
execGame (x : y : rest) (a, b) = execGame rest (a + x, b + y)
