#abc267d. [abc267_d]Index × A(Not Continuous ver.)
[abc267_d]Index × A(Not Continuous ver.)
Problem Statement
You are given an integer sequence of length .
Find the maximum value of for a (not necessarily contiguous) subsequence of length of .
Notes
A subsequence of a number sequence is a sequence that is obtained by removing or more elements from the original number sequence and concatenating the remaining elements without changing the order.
For example, is a subsequence of , but is not a subsequence of .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 2
5 4 -1 8
Sample Output 1
21
When , we have $\\displaystyle \\sum_{i=1}^{M} i \\times B_i = 1 \\times 5 + 2 \\times 8 = 21$. Since it is impossible to achieve or a larger value, the solution is .
Sample Input 2
10 4
-3 1 -4 1 -5 9 -2 6 -5 3
Sample Output 2
54