Олимпиадный тренинг

Задача 38352. Estimate passenger traffic


The bus route passes through N stops (including the final ones). The Passenger Flow Research Department recorded data on how many people got off and how many boarded the bus at each stop. Write a program that will use this data to determine the maximum number of people on this bus at the same time.

Input
The input file contains the number N (2≤N≤100) – number of stops along the route. Next, the number of people who got on the bus at the end is set. Next comes (N-2) pairs of numbers that specify for intermediate stops the number of exits and the number of incoming passengers. Finally, there is a number that specifies the number of people who got off the bus at the final stop.

The number of boarding passengers at each stop did not exceed 100. The data is correct, in particular, the total number of passengers boarding the bus at all stops is always equal to the total number of boarding passengers.

Imprint
In the output file print a single integer — the maximum number of people who at some point simultaneously rode the bus.
 
Examples
# Input Output Explanation
1 5
10
3 1
5 10
0 2
15
15 At the end, 10 people got on the bus. Then 3 went out and 1 went in. There were 8 people on the bus. At the next stop, 5 got off and 10 got on. There were 13 people. At the last intermediate stop, no one got off, but 2 people got on. There were 15 people at the end. Total maximum number of – 15.
2 5
10
10 0
0 0
0 10
10
10 There were 10 people at the final village, who got off at the next stop. After that, at the next stop no one got on and no one got off. Then again, 10 people sat down and reached the end.
3 5

09
34
20
8
10 The bus left the terminal without passengers. Then there were 9 people in it. At the next stop, 3 got off and 4 got on. There were 10 people on the bus. At the next stop, 2 got off and no one got on. 8 people made it to the end. The maximum number of passengers was 10
4 3
100
0 100
200
200 100 people got on the bus at the initial and intermediate stops. 200 people got off the bus.