import Data.List
import GHC.Exts

main :: IO()
main = do
  _ <- getLine
  a <- sortOn Down <$> map read . words <$> getLine
  let b = sum [x | (i,x) <- zip [0..] a, even i]
  let c = sum [y | (i,y) <- zip [0..] a, odd i]
  print $ b - c