import Data.List
main = do
    n <- read <$> getLine :: IO Int
    a <- reverse.sort.map read.words <$> getLine
    let alice = sum.step $ a
          where
            step (x:_:xs) = x:step xs
            step l = l
        total = sum a
    putStrLn.show $ 2*alice - total
