let main () =
  let n = Scanf.scanf "%d\n" Batteries.identity in
  let xs : int array = Array.make n 0 in
  for i = 0 to n - 2 do
    xs.(i) <- Scanf.scanf "%d " Batteries.identity;
  done;
  xs.(n-1) <- Scanf.scanf "%d\n" Batteries.identity;
  Array.sort BatInt.compare xs;
  let alice, bob, _ = Array.fold_right (fun elm (a, b, t) -> if t then (a + elm, b, not t) else (a, b + elm, not t)) xs (0, 0, true) in
  Printf.printf "%d\n" (alice - bob)

let _ = main ()
