Why Did the Cow Cross the Road III (Bronze)#10534

Why Did the Cow Cross the Road III (Bronze)

1 second
128 megabytes
Easy

Farmer John, in his old age, has become paranoid. He built a huge fence around his farm to protect his cows. However, the cows are not happy with this idea.

Neighboring cows can still enter the farm, but only through a single gate, where a long queue often forms, as each cow must answer a long list of questions before entering.

For each of the cows visiting the farm, you are given the time at which she arrives at the gate and the amount of time she needs to answer the entry questions. Only one cow can be undergoing questioning at any given time, so if several cows arrive around the same time, they will have to wait in line and be processed one by one. For example, if a cow arrives at time and spends units of time answering questions, another cow arriving at time must wait until time to begin answering questions.

Determine the earliest possible time by which all cows can enter the farm.

Input

The first line contains n~(n \le 100). Each of the next lines describes one cow by giving the time at which she arrives at the gate and the amount of time she needs to answer the questions. Each of these values is a positive integer not exceeding 10^6.

Output

Print the earliest possible time by which all cows have completed processing.

Examples

In this example, the first cow arrives at time and is processed for unit of time. The gate then remains idle until the third cow arrives at time and begins processing. The second cow arrives at time and must wait until time 5 + 7 = 12 to begin answering questions. She finishes at time 12 + 3 = 15.

Example 1

Loading
Loading