#include<bits/stdc++.h>

#define fill(arr,c) memset(arr,c,sizeof(arr))
#define perm(r) next_permutation(all(r))
//it gives bool value ans permute the string lexoggraphically
#define sortdesc greater<int>()
#define ll long long int 
//std::setfill('0') << std::setw(5) << 25; it adds leaing zeroes;
#define f(i,a) for(ll i=0;i<a;i++)
#define fo(i,a) for(ll i=1;i<=a;i++)
#define foo(i,x,n,c) for(ll i=x;i<n;i+=c)
#define foi(i,x,n,c) for(ll i=x;i>=n;i+=c)
#define fauto(i,m) for(auto i:m)
#define forall(a) for( auto itr=a.begin();itr!=a.end();itr++)
#define ld long double
#define in push_back
#define mll map<ll,ll>
#define mcl map<char,ll>
#define msl map<string,ll>
#define vi vector<int >
#define vl vector<ll >
#define vp vector< pair<int,int> >
#define vs vector <string> 
#define vc vector <char> 
#define o(a) cout<<a
#define os(a) cout<<a<<" "
#define en cout<<"\n";
#define testcase ll t ;cin>>t; while(t--)
#define ff first
#define ss second
#define pl pair<ll,ll>
#define pi pair<int,int>
#define all(a) (a).begin(), (a).end()

#define sz(a)  (a).size()
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
#define bitcount  __builtin_popcountll
#define imin o("imin");en;
using namespace std;
bool comp(const pair<int,int> &a , const pair<int,int> &b){
    if(a.first == b.first)  return a.second < b.second;
     return a.first < b.first;
}
bool comps(const pair<int,int> &a , const pair<int,int> &b){
    if(a.second == b.second)  return a.first< b.first;
     return a.second < b.second;
}
bool compmx(int a, int b) 
{ 
    return (a < b); 
} 
//ll pi=acos(0.0)*2;
void fastio()
{
    	ios::sync_with_stdio(0);
cin.tie(0);

}
void inout()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

     freopen("output.txt", "w", stdout);
     #endif
}

int main()
{
fastio();
inout();
ll n;
cin>>n;
ll a[n];
f(i,n)
cin>>a[i];
ll ans=0;

f(i,n)
{
   // os(1);
ll cur=a[i];
    foo(j,i+1,n,1)
    {
if(a[j]>=a[i])
{
cur+=a[i];
}
else
break;
    }
    foi(j,i-1,0,-1)
    {
if(a[j]>=a[i])
{
cur+=a[i];
}
else
break;
    }
    ans=max(ans,cur);
}
o(ans);
return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

int n;
int a[10001];
int mn[10001][10001];

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin>>n;
	forn(i,0,n)
		cin>>a[i];
	forn(i,0,n){
		mn[i][i]=a[i];
		forn(j,i+1,n)
			mn[i][j]=min(mn[i][j-1],a[j]);
	}
	int res=-1;
	forn(i,0,n){
		int mx=-1;
		forn(j,i,n)
			mx=max(mx,mn[i][j]*(j-i+1));
		res=max(res,mx);
	}
	cout<<res<<endl;
	return 0;
}