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) *)
let get_max a used =
  fold_int
    (fun (ma, j) i ->
      if used.(i) then
        ma, j
      else
        if a.(i) > ma then a.(i), i else ma, j)
    (-1, -1)
    (Array.length a)

(* O(N^2) *)
let solve n a_s =
  let a_s = list_to_array n 0 a_s in
  let used = Array.make n false in
  fold_int
    (fun sofar i ->
      let ma, j = get_max a_s used in
      used.(j) <- true;
      if i mod 2 = 0 then
        sofar + ma (* Alice *)
      else
        sofar - ma) (* 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