#P1580D. Subsequence
Subsequence
No submission language available for this problem.
Description
Alice has an integer sequence of length and all elements are different. She will choose a subsequence of of length , and defines the value of a subsequence as where denotes .
Alice wants you to help her to maximize the value of the subsequence she choose.
A sequence is a subsequence of a sequence if can be obtained from by deletion of several (possibly, zero or all) elements.
The first line contains two integers and ().
The second line contains distinct integers ().
Print the maximal value Alice can get.
Input
The first line contains two integers and ().
The second line contains distinct integers ().
Output
Print the maximal value Alice can get.
Samples
Note
In the first example, Alice can choose the subsequence , which has the value . In the second example, there are a variety of subsequences with value , and one of them is .