Hide

Problem B
Bus Assignment

The Institution for Carrying People Carefully is responsible for managing the famous Line Bus in Line Town. The Line Bus goes through $n$ stops conveniently numbered from $1$ to $n$. At stop $i$, $a_i$ people first get off the bus. Then, $b_i$ people get on the bus. The bus starts out empty at stop $1$ and then goes through the stops in numerically increasing order, eventually stopping at stop $n$ where the bus empties.

When someone rides the Line Bus, they must be seated. A bus with capacity $c$ has exactly $c$ seats for passengers. Each rider of the Line Bus occupies exactly one seat. The driver of the Line Bus is not counted. The Institution for Carrying People Carefully wants to know what is the minimum capacity bus needed to run the Line Bus.

Input

The first line contains a single integer, $n$ $(2 \le n \le 2 \cdot 10^5)$.

Each of the next $n$ lines contains two integers, $a_i$ and $b_i$ $(0 \le a_i, b_i \le 10^9)$. It is guaranteed that at least one person boards the bus, at most $10^9$ people board the bus over all stops, and that the bus will empty at stop $n$.

Output

Output a single integer, the minimum capacity bus needed to run the Line Bus.

Sample Input 1 Sample Output 1
4
0 3
1 2
2 1
3 0
4

Please log in to submit a solution to this problem

Log in