open System
let readInt () = stdin.ReadLine() |> int
let readIntArray () = stdin.ReadLine().Split(' ') |> Array.map int

let N = readInt ()
let A = readIntArray () |> Array.sortWith (fun a b -> a.CompareTo b |> (*) -1);

let rec takeFirst xs =
    match xs with
        | []   -> 0
        | x :: [] -> x
        | _    -> xs.[0] + takeFirst (Seq.skip 2 xs)


let total = A |> Array.sum
let alice = Array.toSeq A |> takeFirst
let bob = total - alice
printfn "%d" (alice - bob)
