Question
The Kraken's Last Dam

A harbour engineer is designing a seawall. She has n vertical pillars arranged in a line, each with a given height. She wants to choose two pillars to form the walls of a water barrier — the barrier can hold water up to the height of the shorter pillar, and its capacity equals that shorter height multiplied by the horizontal distance between the two pillars.

Find the maximum water capacity any such pair of pillars can hold.

Input

The first line contains KaTeX can only parse string typed expression. The second line contains KaTeX can only parse string typed expression space-separated non-negative integers — the heights of the pillars.

Output

A single integer — the maximum water capacity.

Example
Example 1:
Input
9

1 8 6 2 5 4 8 3 7
Output
49
Explanation
Pillars at positions 1 and 8 (0-indexed) with heights 8 and 7 give capacity min(8,7) × 7 = 49.

Example 2:
Input
2

1 1
Output
1

Online