Statement
Dadas is farming on a number line. Initially, there are planted seeds. Seed is located at coordinate , and all seed positions are distinct.
Seed has value . It can be harvested only on day .
Dadas may choose any initial position on the number line. Dadas may also choose not to harvest a seed on a day. To harvest seed on day , Dadas must move from the current position to .
If there is an unharvested seed strictly between the current position and , Dadas steps on it while moving. A stepped-on seed can never be harvested later. The target seed itself is not considered stepped on.
Choose which seeds to harvest to maximize the total value obtained.
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
Output
For each test case, print the maximum total value that can be obtained on one line.
Constraints
- .
- .
- ().
- ().
- ().
- The sum of over all test cases does not exceed .