#include<iostream> using namespace std; const int maxn = 105; int n,h[maxn]; int S(int i){ int j,k,t; for(j=i;j>=1;j--){ if(h[j]<h[i])break; } j++; for(k=i;k<=n;k++){ if(h[k]<h[i])break; } k--; t = min(h[j],h[i]); t = min(t,min(h[i],h[k])); t = t*(k-j+1); return t; } int main(){ while(cin>>n){ for(int i=1;i<=n;i++){ cin>>h[i]; } int ans = 0; for(int i=1;i<=n;i++){ ans = max(ans,S(i)); } cout<<ans<<endl; } return 0; }