#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define all(v) begin(v),end(v)
#define pb push_back
#define fr first
#define sc second
#define si(s) (int)s.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
const int M = 1e9+7;
const int N = 1e5+5;
ll power(ll a, ll n) { 
ll res = 1; 
while (n) { 
if (n % 2) {res = (res * a) % M;} 
n >>= 1; a = (a * a) % M;} 
return res;
}
void solve(){
	int n;
	cin>>n;
	vector<ll> a(n);
	for(auto &x:a){
		cin>>x;
	}
	ll ma = INT_MIN;
	for(int i=0;i<n;i++){
		ll s = a[i];
		for(int j=i-1;j>=0;j--){
			if(a[i]<=a[j]){
				s+=a[i];
			}
			else{
				break;
			}
		}
		for(int j=i+1;j<n;j++){
			if(a[i]<=a[j]){
				s+=a[i];
			}
			else{
				break;
			}
		}
		ma = max(ma,s);
	}
	cout<<ma;
}
int main(){
	fast;

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif

	int tc=1; //cin>>tc;
	while(tc--){
		solve();
	}	
	return 0;
}

#include <bits/stdc++.h>
#define PRINT(x) cerr<<#x<<'='<<x<<endl
#define NL(x) " \n"[(x)]
#define sz(x) int((x).size())
#define all(x) begin(x),end(x)
#define mid (l+r)/2
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define lld long long
#define pii pair<int,int>
#define pli pair<lld,int>
#define pil pair<int,lld>
#define pll pair<lld,lld>
#define INF 1000000000
#define LINF 1000000000000000000LL
#define EPS 1e-9
using namespace std;
#define MAXN 10010
lld A[MAXN];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int N; cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i];
    long long rez = 0;
    for(int i = 1; i <= N; i++) {
        lld minn = INF;
        for(int j = i; j <= N; j++) {
            minn = min(minn, A[j]);
            rez = max(rez, minn*(j-i+1));
        }
    }
    cout << rez;
    return 0;
}
