open System

let read() = Console.ReadLine()

let N = read() |> int
let A = read().Split()
        |> Array.map(int)
        
A
|> Array.sortDescending
|> Array.indexed
|> Array.fold (fun acc x -> 
        if fst x % 2 = 0 then acc + (snd x)
        else                  acc - (snd x)
        ) 0
|> printfn "%i"        
                
