Pogo-Cow

No attempts yetTime limit1sMemory limit128 MB

Problem

Farmer John wanted his prize cow Bessie to get around faster, so he attached a pogo stick to each of her legs. It was not a good idea. Bessie now hops across the farm quickly, but she has not learned how to slow down.

To train Bessie to control her hops, Farmer John built a practice course along a straight path across the farm. He placed NN targets at distinct positions on the path for Bessie to land on (1N10001 \le N \le 1\,000). Target ii sits at position xix_i and is worth pip_i points when Bessie lands on it.

Bessie picks any one target to start on and then moves in a single direction, hopping from target to target. No hop may be shorter than the hop before it, and every hop has to land on a target. The first hop has no length restriction.

Every target Bessie touches scores, including the one she starts on. Find the largest number of points she can collect.

Input

The first line has the number of targets NN. The ii-th of the next NN lines has the position xix_i and the value pip_i of target ii, both integers in the range 00 to 10000001\,000\,000. All target positions are distinct.

Output

Print the largest number of points Bessie can collect.

Hint

In the sample Bessie starts at position 44 and hops to position 55, then position 77, then position 1010. The hop lengths 11, 22, 33 never shrink, and the score is 8+6+6+5=258 + 6 + 6 + 5 = 25.