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 N targets at distinct positions on the path for Bessie to land on (1≤N≤1000). Target i sits at position xi and is worth pi 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.
The first line has the number of targets N. The i-th of the next N lines has the position xi and the value pi of target i, both integers in the range 0 to 1000000. All target positions are distinct.
Print the largest number of points Bessie can collect.
In the sample Bessie starts at position 4 and hops to position 5, then position 7, then position 10. The hop lengths 1, 2, 3 never shrink, and the score is 8+6+6+5=25.