import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- reverse . sort . map (read::String -> Int) . words <$> getLine
  let (former, latter, _) = foldl (\(f, l, state) val -> if state then (f + val, l, False) else (f, l + val, True)) (0, 0, True) arr
  print $ former - latter

