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

a
|> Array.sortDescending
|> Array.mapi (fun i x ->
    match i%2 with
    | 1 -> -x
    | 0 -> x)
|> Array.sum
|> stdout.WriteLine