#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
stack s;
s.push(0);
int i;
int area;
int max_area=0;
for(i=1;i<n;i++){
while(a[i]<a[s.top()] && s.empty()==false){
int x=a[s.top()];
s.pop();
if(!s.empty()){
area=x*(i-s.top()-1);
}
else{
area=x*i;
}
if(area>max_area){
max_area=area;
}
}
s.push(i);
}
while(!s.empty()){
int x=a[s.top()];
s.pop();
if(!s.empty()){
area=x*(i-s.top()-1);
}
else{
area=x*i;
}
if(area>max_area){
max_area=area;
}
}
cout<<max_area<<endl;
return 0;
}
whats the problem in this code it is giving right ans on online compiler but in hackerblocks its giving time error