Code Submission Evaluation System Login

CSES Problem Set

Advertisement


Task | Statistics


CSES - Advertisement

Time limit:1.00 s Memory limit:512 MB

A fence consists of $n$ vertical boards. The width of each board is 1 and their heights may vary.

You want to attach a rectangular advertisement to the fence. What is the maximum are of such an advertisement?

Input

The first input line contains an integer $n$: the width of the fence.

After this, there are $n$ integers $k_1,k_2,\ldots,k_n$: the height of each board.

Output

Print one integer: the maximum area of an advertisement.

Constraints
Example

Input:
8
4 1 5 3 3 2 4 1


Output:
10