{-# LANGUAGE ScopedTypeVariables #-}

import Data.List

main :: IO ()
main = do
    _ :: Int <- read <$> getLine
    as :: [Int] <- reverse . sort . map read . words <$> getLine
    print (( sum $ takeOdds as) - (sum $takeEvens as))

takeOdds :: [a] -> [a]
takeOdds [] = []
takeOdds [a] = [a]
takeOdds (a:_:as) = a:takeOdds as

takeEvens :: [a] -> [a]
takeEvens [] = []
takeEvens (_:as) = takeOdds as