n = gets.to_i
a,b = n.times.map{gets.chomp.split.map(&:to_i)}.transpose
takahashi = aoki = 0
diff = []
a.push(0)
b.push(0)
ar = a.sort!.reverse!
br = b.sort!.reverse!
n.times do |i|
  diff.push([a[i] - b[i] , i])
end
diff.sort!
n.times do |j|
    if j.even?
      if ar[j] > ar[j+1]
        takahashi += a[j]
      else
         t = diff.shift
         takahashi += a[t[1]]
       end
    else
      if br[j] > br[j+1]
        aoki += b[j]
      else
        _a = diff.pop
        aoki += b[_a[1]]
      end
    end
end
p takahashi - aoki
