import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
    _ <- getLine
    str <- words <$>getLine
    let card = reverse $sort $map read str 
    let aliceScore = alice card
    let totalScore = sum card
    print (aliceScore*2 - totalScore)

alice [] = 0
alice [x] = x
alice (x1:_:xs) = x1 + alice xs
