 #include<bits/stdc++.h>
#include<stdlib.h>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<queue>
#include<time.h>
#include <cstdio>
#include <iostream>
#include <vector>
#define ll long long
#define int long long
#define inf 0x3f3f3f3f
#define mods 1000000007
#define modd 998244353
#define PI acos(-1)
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define mp make_pair
#define pb push_back
#define si size()
#define E exp(1.0)
#define fixed cout.setf(ios::fixed)
#define fixeds(x) setprecision(x)
#define IOS ios::sync_with_stdio(false);cin.tie(0)
 using namespace std;
 ll gcd(ll a,ll b){if(a<0)a=-a;if(b<0)b=-b;return b==0?a:gcd(b,a%b);}
template<typename T>void read(T &res){bool flag=false;char ch;while(!isdigit(ch=getchar()))(ch=='-')&&(flag=true);
for(res=ch-48;isdigit(ch=getchar());res=(res<<1)+(res<<3)+ch - 48);flag&&(res=-res);}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll qp(ll a,ll b,ll mod){ll ans=1;if(b==0){return ans%mod;}while(b){if(b%2==1){b--;ans=ans*a%mod;}a=a*a%mod;b=b/2;}return ans%mod;}//快速幂%
ll qpn(ll a,ll b, ll p){ll ans = 1;a%=p;while(b){if(b&1){ans = (ans*a)%p;--b;}a =(a*a)%p;b >>= 1;}return ans%p;}//逆元   (分子*qp(分母,mod-2,mod))%mod;

ll a[11111];
ll last[11111];
ll pre[11111];
signed main(){
 ll n;
 read(n);
 ll mi=1e9;
 for(int i=1;i<=n;i++){
 read(a[i]);
 mi=min(mi,a[i]);
 last[i]=n;
 pre[i]=1;
 }

 ll ans=0;
 for(int i=1;i<=n;i++){
 for(int j=i-1;j>=1;j--){
 if(a[j]<a[i]){
    pre[i]=j+1;
    break;
 }

 }

 for(int j=i+1;j<=n;j++){
        //i=L
 if(a[j]<a[i]){
    last[i]=j-1;
    break;
 }

 }

 }

 for(int i=1;i<=n;i++){
 ll len=last[i]-pre[i]+1;
 ans=max(ans,len*a[i]);
 }
printf("%lld",ans);

}

#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define F first 
#define S second 
#define pb push_back 

using namespace std;

void test(){
	ll n;
	cin>>n;
	ll a[n];
	f(i,n)cin>>a[i];
	ll res = a[0];
	f(i,n){
		ll c = 0, s = a[i];
		for(int j=i;j<n;j++){
			c++;
			s = min(s,a[j]);
			res = max(res,s*c);
		}
	}
	cout<<res<<"\n";
	
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	// cin>>tests;
	while(tests--){
		test();
	}
}
