n=gets.to_i;
a=[]
n.times{
  a<<gets.split.map(&:to_i)
}
sum=0
n.times{|j|
  if j%2==0
    a=a.sort_by{|i|i[0]}
    sum+=a[0][0]
    a.delete_at(0)
  else
    a=a.sort_by{|i|i[1]}
    sum-=a[0][1]
    a.delete_at(0)
  end
}
puts sum