2660. Find Max

单点时限: 2.0 sec

内存限制: 256 MB

We all know RMQ – ( Range Minimum/Maximum Query ), we can use it to solve such problems as find the Minimum value in a interval, for example, 1, 2, 3, 4, 2, 4, 6, 1, 8 , if you want know the Minimum value in [1, 7],

you can use RMQ to solve it in O(1) time. But now, I want to know another thing. We choose a interval and sum all the value in that interval, then multiply the Minimum value in that interval. Now I want to make this value maximum.

输入格式

The first line of the input contains n (1 <= n <= 100 000), the follows n numbers.

All input data are positive integer.

输出格式

For each case, output the maximum value define above.

样例

Input
6
3 1 6 4 5 2
4
1 100 100 1
Output
60
20000

12 人解决,29 人已尝试。

20 份提交通过,共有 298 份提交。

7.2 EMB 奖励。

创建: 16 年前.

修改: 8 年前.

最后提交: 5 天,13 小时前.

来源: N/A

题目标签