open System
let n = stdin.ReadLine() |> int
let cards = stdin.ReadLine().Split(' ') |> Array.map int |> Array.toList
let sortedCards = cards |> List.sortDescending

let helper a b =
    if a < b then (Some b, Some a) else (Some a, Some b)

let rec pop (pairs: (int option * int option) list) (reminder: int list) =
    match reminder with
    | [] -> pairs
    | [ a ] -> (Some a, None) :: pairs
    | a :: b :: rem -> pop ((helper a b) :: pairs) rem

let bind x =
    match x with
    | Some a -> a
    | None -> 0

pop [] sortedCards
|> List.map (fun x -> (x |> fst |> bind, x |> snd |> bind))
|> List.fold (fun x y -> (fst x + fst y, snd x + snd y)) (0,0)
|> fun x -> fst x - snd x
|> printfn "%d"