let N = stdin.ReadLine()

stdin.ReadLine().Split(' ') |> Array.map int
|> Array.sortBy (fun x -> -x)
|> fun arr -> Array.zip [|1..(Array.length arr)|] arr
|> Array.partition (fun (id,x) -> id%2=1)
|> fun (arrAlice, arrBob) -> (Array.sumBy snd arrAlice) - (Array.sumBy snd arrBob)
|> printfn "%d"