Under construction

Still being built. Things may change

Bus Assignment

Interview

Time limit2sMemory limit2048 MB

Summary
Given how many people get off and get on at each stop, find the maximum number of passengers on the bus at any one time.
Level

Easy2 of 10

Topics
Simulation, Array
Solved
No attempts yet

Statement

The Institution for Carrying People Carefully manages the famous Line Bus in Line Town. The Line Bus passes through nn stops numbered from 11 to nn. At stop ii, aia_i people get off the bus first, and then bib_i people get on. The bus starts empty at stop 11, visits the stops in increasing order, and empties at stop nn.

A passenger on the Line Bus must have a seat. A bus with capacity cc has exactly cc seats for passengers, and each rider occupies one seat. The driver is not counted. The institution wants the minimum capacity needed to run the Line Bus.

Input

The first line contains an integer nn (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5).

Each of the next nn lines contains two integers aia_i and bib_i (0≤ai,bi≤1090 \le a_i, b_i \le 10^9). At least one person boards the bus, the total number of boarding people over all stops is at most 10910^9, and the bus is empty after stop nn.

Output

Print a single integer, the minimum capacity of the bus.

Examples1

  1. Example 1

    Input
    4
    0 3
    1 2
    2 1
    3 0
    
    Expected output
    4