n=gets.to_i
mat = Array.new(2){gets.split.map(&:to_i)}.transpose
f=0

0.upto((1<<n)-1) do |bit|
  tmp = 0
  0.upto(n-1) do |i|
  	if (bit>>i)&1 == 1
      tmp+=mat[i][0]-mat[i][1]
    end
  end
  
  if tmp > f
    f = tmp
  end
  
end

p f