Problems
#852
~/algor $ cat problems/VEHsRsym5zBI
Bus capacity
Easy
1000 ms
64 MB
19%
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?
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