#asaporod. [asaporo_d]Struck Out
[asaporo_d]Struck Out
Problem Statement
There are panels arranged in a row in Takahashi's house, numbered through . The -th panel has a number written on it. Takahashi is playing by throwing balls at these panels.
Takahashi threw a ball times. Let the panel hit by a boll in the -th throw be panel . He set the score for the -th throw as .
He was about to calculate the total score for his throws, when he realized that he forgot the panels hit by balls, . The only fact he remembers is that for every , holds. Based on this fact, find the maximum possible total score for his throws.
Constraints
Partial Scores
- In the test set worth points, .
- In the test set worth another points, and .
- In the test set worth another points, .
Input
The input is given from Standard Input in the following format:
…
Output
Print the maximum possible total score for Takahashi's throws.
Sample Input 1
5 2 3
10 2 8 10 2
Sample Output 1
56
The total score is maximized when panels and are hit, in this order.
Sample Input 2
5 5 2
5 2 10 5 9
Sample Output 2
28
This case satisfies the additional constraint for a partial score.
Sample Input 3
10 3 5
3 7 2 6 9 4 8 5 1 1000000000
Sample Output 3
5000000078