let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let a_lst_sorted = List.sort (fun x y -> compare y x) a_lst in

  let div lst =
    let rec aux even odd i = function
        [] -> (even, odd)
      | hd :: tl -> if i mod 2 = 0 then
          aux (hd::even) odd (i+1) tl
        else
          aux even (hd::odd) (i+1) tl
    in
    aux [] [] 0 lst
  in

  let a, b = div a_lst_sorted in
  let ans = (List.fold_left (+) 0 a) - (List.fold_left (+) 0 b) in

  Printf.printf "%d\n" ans
