open System

let n = stdin.ReadLine() |> int
let a =
    stdin.ReadLine().Split()
    |> Array.map int
    |> Array.sortDescending

let alice =
    Array.mapi (fun i x -> x * (1 - i % 2)) a
    |> Array.sum

let bob =
    Array.mapi (fun i x -> x * (i % 2)) a
    |> Array.sum

printfn "%d" <| alice - bob