只要告诉我为什么RE就好QWQ
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define MAXN 100005
using namespace std;
struct node{
int con,val;
};
int n,a[MAXN],ans;
stack<node> s;
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
while(n!=0){
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
int num=0;
while(!s.empty() and s.top().val>=a[i]){
num=s.top().con;
ans=max(ans,s.top().con*s.top().val);
s.pop();
s.top().con+=num;
}
s.push({num+1,a[i]});
}
while(!s.empty()){
int num=s.top().con;
ans=max(ans,s.top().con*s.top().val);
s.pop();
s.top().con+=num;
}
cout<<ans<<endl;
cin>>n;
}
return 0;
}