let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let ab = Array.to_list @@ Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a, b)
let ab = List.sort (fun (a, b) (c, d) -> (c + d) - (a + b)) ab

type next = T | A

let rec loop sum_t sum_a next rest = match (next, rest) with
  | (_, []) -> sum_t - sum_a
  | (T, (a, _) :: xs) -> loop (sum_t + a) sum_a A xs
  | (A, (_, b) :: xs) -> loop sum_t (sum_a + b) T xs

let () = Printf.printf "%d\n" @@ loop 0 0 T ab