open Batteries;;

let rec card : int -> int -> int list -> int =fun a b l ->
  match l with
  | [] -> abs (a-b)
  | e :: rest ->
     card b (a+e) rest
    in
    
  let _ = read_line () in
  let lista = read_line () |> String.split_on_char ' ' |> List.map int_of_string in
  let l = List.rev(List.sort (Pervasives.compare) lista) in
  let diff = card 0 0 l in
  print_int diff
;;
