#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int h[N];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
scanf("%d",&h[i]);
}
int res=0;
for(int i=0;i<=n;i++)
{
int l=i,r=i;
while(l>=1&&h[l]>=h[i]) l--;
while(r<=n&&h[r]>=h[i]) r++;
int s=(r-l-1)*h[i];
res=max(res,s);
}
cout<<res;
return 0;
}