let n = stdin.ReadLine() |> int
stdin.ReadLine().Split(' ')
    |> Array.map int
    |> Array.sort
    |> Array.rev
    |> Array.indexed
    |> Array.sumBy (fun (i, c) -> if i % 2 = 0 then c else -c )
    |> printfn "%d"
