open Core

let n = Scanf.scanf "%d" ident

let a =
  List.init n ~f:(fun _ -> Scanf.scanf " %d" Fn.id)
  |> List.sort ~compare:Int.compare |> List.rev

let alice =
  List.mapi ~f:(fun i n -> if i mod 2 = 0 then n else 0) a
  |> List.fold_left ~f:( + ) ~init:0

let bob =
  List.mapi ~f:(fun i n -> if i mod 2 = 1 then n else 0) a
  |> List.fold_left ~f:( + ) ~init:0

let () = Printf.printf "%d\n" (alice - bob)
