let fold_int f a n =
  let rec fold f a i n =
    if i >= n then
      a
    else
      fold f (f a i) (i + 1) n
  in
    fold f a 0 n

let list_to_array n a xs =
  let res = Array.make n a in
  List.iteri (fun i x -> res.(i) <- x) xs;
  res

(* O(n * log(n)) *)
let solve n a_s =
  let sorted_as = list_to_array n 0 a_s in
  Array.sort (fun x y -> compare x y * -1) sorted_as;
  fold_int
    (fun sofar i ->
      if i mod 2 = 0 then
        sofar + sorted_as.(i) (* Alice *)
      else
        sofar - sorted_as.(i)) (* Bob *)
    0
    n

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  let n = read_int () in
  let a_s = read_ints () in
  solve n a_s |> string_of_int |> print_endline