n = gets.to_i
max = tunnel = gets.to_i
n.times{
    a, b = gets.chomp.split.map(&:to_i)
    tunnel += (a - b)
    max = tunnel if max < tunnel
    if tunnel < 0
        max = 0
        break
    end
}
puts max
