input1 = gets
num1 = input1.to_i - 1

ary1 = Array.new(num1)
ary2 = Array.new(num1)
for num in 0..num1 do
  input2 = gets
  str = input2.split(" ")
  ary1[num] = str[0].to_i
  ary2[num] = str[1].to_i
end 

numa = 0
numb = 0

while ary1.length > 0  do
  max1 = ary1.max
  max2 = 0
  for num in 0..ary1.length-1 do
    if max1 == ary1[num] then
      if  ary2[num] > max2 then
        idx1 = num
        max2 = ary2[num]
      end
    end
  end 
  #puts idx1.to_s + " max1:" + max1.to_s

  numa += max1
  ary1.delete_at(idx1)
  ary2.delete_at(idx1)

  if ary1.length == 0 then
    break
  end

  max2 = ary2.max
  max1 = 0
  for num in 0..ary2.length-1 do
    if max2 == ary2[num] then
      if  ary1[num] > max1 then
        idx2 = num
        max1 = ary1[num]
      end
    end
  end 
  #puts idx2.to_s + " max2:" + max2.to_s

  numb += max2
  ary1.delete_at(idx2)
  ary2.delete_at(idx2)

end

puts (numa - numb).to_s
