Problem8586--DPL_3_C : Largest Rectangle in a Histogram

8586: DPL_3_C : Largest Rectangle in a Histogram

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

A histogram is made of a number of contiguous bars, which have same width.

For a given histogram with $N$ bars which have a width of 1 and a height of $h_i = h_1,h_2,...,h_N$ respectively, find the area of the largest rectangular area.

Input

The input is given in the following format.

$N$
$h_i = h_1,h_2,...,h_N$

Output

Print the area of the largest rectangle.

Constraints

$1≤N≤10^5$
$0≤h_i≤10^9$

Sample 1 Input

8
2 1 3 5 3 4 2 1

Sample 1 Output

12

Sample 2 Input

3
2 0 1

Sample 2 Output

2

HINT

相同题目:DPL_3_C

Source/Category