#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i,a,b) for (i=(a);i<=(b);i++)
#define CLEAR(a) memset((a),0,sizeof((a)))
using namespace std;
typedef long long LL;
const double pi = acos(-1.0);
const int maxn=1e5;
void init();
void outp();
int r[maxn+10], l[maxn+10];
LL s[maxn+10];
int main()
{
int n=0;
while (~scanf("%d",&n)&&n)
{
for (int i = 1; i <= n; i++) {
scanf("%I64d", &s[i]);
l[i] = r[i] = i;
}
s[n + 1] =s[0] = -1;
for (int i = 1; i <= n; i++) {
while (s[l[i] - 1] >= s[i]) l[i] = l[l[i] - 1];
}
for (int i = n; i >= 1; i--) {
while (s[i] <= s[r[i] + 1]) r[i] = r[r[i] + 1];
}
LL ans=0, tmp;
for (int i = 1; i <= n; i++) {
tmp = s[i]*(r[i] - l[i] + 1) ;
if (tmp > ans)ans = tmp;
}
printf("%I64d\n", ans);
//outp();
}
return 0;
}
void init()
{
}
void outp()
{
}
hdu 1506
最新推荐文章于 2024-06-30 10:57:50 发布