Skip to main content

~/algor $ cat contests/round-6/D

D. Bus capacity

Problem D ICPC rules 1000 ms 64 MB

A bus route has stops, and the bus arrives at the first stop empty. At stop , first passengers get off the bus, then passengers get on. What is the smallest number of seats the bus must have so that all passengers fit?

Four stops, the number of passengers getting off and on at each, the number of passengers on the bus between the stops, the largest is 6

Input

The first line contains a positive integer . Line of the next lines contains two integers: and .

Output

One integer — the smallest number of seats.

Note




does not exceed the number of passengers on the bus

Examples

Input #1
4
0 3
1 4
5 2
3 0
Output #1
6
Input #2
2
0 0
0 0
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.