cho.sh
Notes
Loading...

Intelligent Train 2

Time limit

1s

Memory limit

128 MB

Problem

An intelligent train runs through 10 stations from station 1 (departure) to station 10 (terminal) in order. At each station, a device records how many passengers get off and how many get on. Passengers always board only after everyone who wants to get off has left.

The records for all 10 stations satisfy these conditions.

  1. The train visits stations in increasing station-number order.
  2. Nobody gets off at the departure station, and nobody gets on at the terminal station.
  3. At no station do more passengers get off than are currently on the train.
  4. The train capacity is 10,000 passengers, and it is never exceeded.

After subtracting the number getting off and then adding the number getting on at each station, find the maximum number of passengers that were on the train at any point during the trip.

Input

Ten lines are given, one for each station in order from the first station to the tenth. Each line contains two space-separated integers: the number of passengers who get off and the number of passengers who get on at that station.

Output

Print the maximum number of passengers that were on the train during the trip.