let rec play cards alice bob =
    match cards with
        | []             -> alice - bob
        | [x]            -> (alice + x) - bob
        | x1 :: x2 :: xs -> play xs (alice + x1) (bob + x2)

let () =
    let _ = read_int () in
    let cards =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string
		|> List.sort (fun m n -> compare n m)
    in print_endline (string_of_int (play cards 0 0))
