Product
Given an array of length . The cost of a subarray is defined as the product of the length of the subarray and the sum of its two smallest numbers.
A subarray is a part of the array that includes only the elements located at positions from to , inclusive.
For example, let the array be . Let us consider the subarray , which consists of elements () . Its length is , its first minimum is , and its second minimum is . Therefore, its cost is . Let us consider another subarray, , consisting of elements () . Its length is , its first minimum is , and its second minimum is . Therefore, its cost is .
Note that if the minimum number occurs more than once, it is counted several times. For example, if there is a subarray , its length is , its first minimum is , and its second minimum is . Therefore, its cost is .
Your task is to find the maximum cost over all subarrays of length at least two elements. That is, you need to find the maximum cost over all subarrays , where .
Input
The first line contains a single integer .
The second line contains integers .
Output
Output a single integer – the answer to the problem.
Examples
Note
In the first example, the maximum cost is achieved for the subarray , its length is , its minimums are and , and the product of .
In the second example, the maximum cost is achieved for the subarray , its length is , its minimums are and , and the product of .
In the third example, the maximum cost is achieved for the subarray , its length is , its minimums are and , and the product of .
Scoring
( points):
( points):
( points):
( points): All tests are generated randomly in the following way: first, a number is determined, which does not happen randomly, and then each ( ) is assigned a value from to inclusively with equal probability for each value. .
( points):
( points): No additional constraints.