import Data.List

main = do
  _ <- getLine
  ai <- map read . words <$> getLine
  print . diffAliceBob' . reverse $ sort ai

diffAliceBob' :: [Int] -> Int
diffAliceBob' ns = if ((length ns) `mod` 2) == 0
  then diffAliceBob ns
  else diffAliceBob (init ns) + (head $ reverse ns)

diffAliceBob :: [Int] -> Int
diffAliceBob [] = 0
diffAliceBob (a:b:ns) = (a  - b) + diffAliceBob ns
