Trapped in the Haybales

No attempts yetTime limit1sMemory limit256 MB

Problem

Farmer John received a shipment of NN large hay bales (1N1000001 \le N \le 100000) and placed them at various points along the road that leads to his barn. He forgot that Bessie the cow was grazing along that road, so she may now be trapped between the bales.

Bale jj has size SjS_j and sits at position PjP_j on the one-dimensional road. Bessie moves freely along the road and can walk right up to the position of a bale, but she cannot cross that position. There is one exception. If she runs in the same direction for a distance of DD, she builds up enough speed to break through and permanently remove any bale whose size is strictly less than DD. Removing a bale opens up more room to run, so she sometimes breaks further bales after that.

Bessie escapes if she eventually breaks through the leftmost bale or the rightmost bale. Compute the total length of the real-valued starting positions from which Bessie cannot escape.

Input

The first line contains NN. Each of the next NN lines describes one bale with two integers, its size and then its position. Both values are between 11 and 10910^9. All positions are distinct.

Output

Print one integer, the length of the part of the road from which Bessie cannot escape.