open System

[<EntryPoint>]
let main _ =
    let n = stdin.ReadLine() |> int
    let a = stdin.ReadLine().Split() |> Array.map int
    a
    |> Array.sortDescending
    |> Array.indexed
    |> Array.sumBy (fun (id, x) -> if id % 2 = 0 then x else -x)
    |> stdout.WriteLine
    0
