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

10 人解决,26 人已尝试。

16 份提交通过,共有 277 份提交。

7.6 EMB 奖励。

创建: 15 年,4 月前.

修改: 7 年,3 月前.

最后提交: 3 月,4 周前.

来源: N/A

题目标签