#D10353. Sequence
Sequence
Sequence
Problem
There are arithmetic progressions with the number of terms . The first term of the arithmetic progression is and the tolerance is . Arrange the first sequence, the second sequence, ..., the sequence in order from the first sequence, and let the resulting sequence be . Then, when you select an arbitrary interval of length from and create a new sequence , maximize the sum of the sequence .
Constraints
The input satisfies the following conditions.
- All inputs are integers
Input
The input is given in the following format.
...
Three integers , , are given on the first line, separated by blanks. In the following row, the arithmetic progression information , is given, separated by blanks.
Output
Outputs the maximum value of the sum of the sequence on one line.
Examples
Input
3 3 5 0 3 2 2 4 1
Output
25
Input
3 3 5 0 10 8 1 11 1
Output
58
inputFormat
input satisfies the following conditions.
- All inputs are integers
Input
The input is given in the following format.
...
Three integers , , are given on the first line, separated by blanks. In the following row, the arithmetic progression information , is given, separated by blanks.
outputFormat
Output
Outputs the maximum value of the sum of the sequence on one line.
Examples
Input
3 3 5 0 3 2 2 4 1
Output
25
Input
3 3 5 0 10 8 1 11 1
Output
58
样例
3 3 5
0 10
8 1
11 1
58