#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i=0; i<N; i++) cin >> A[i];

    vector<vector<long long> > mintable(N, vector<long long>(N, 100001));

    for (int left=0; left<N; left++) {
        for (int right=left; right<N; right++) {
            if (right == left) {
                mintable[left][right] = A[left];
                continue;
            }
            mintable[left][right] = min(mintable[left][right-1], A[right]);
        }
    }

    long long best = 0;
    for (int left=0; left<N; left++) {
        for (int right=left; right<N; right++) {
            best = max(best, mintable[left][right] * (1+right-left));
        }
    }
    cout << best << endl;
    return 0;
}
#include <bits/stdc++.h>

#define psk push_back
#define ppk pop_back
#define mkp make_pair

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef unsigned int u32;
typedef unsigned short u16;

typedef pair<int,int> PII;
typedef pair<LL,int> PLI;
typedef pair<int,LL> PIL;
typedef pair<LL,LL> PLL;
typedef map<int,int> MII;
typedef map<LL,int> MLI;
typedef map<int,LL> MIL;
typedef map<LL,LL> MLL;
typedef vector<int> VI;
typedef vector<PII > VII;
typedef vector<LL> VL;
typedef queue<int> QI;
typedef queue<PII > QII;

const short MSK15=0x7fff;
const u16 MSK16=0xffff;
const int MSK31=0x7fffffff;
const u32 MSK32=0xffffffff;
const LL MSK63=0x7fffffffffffffff;
const uLL MSK64=0xffffffffffffffff;
const int Inf=(1<<30)-1;
const int mInf1=0x3f3f3f3f;
const int mInf2=0x7f7f7f7f;
const LL lInf=(1LL<<62)-1;
const LL lmInf1=0x3f3f3f3f3f3f3f3fLL;
const LL lmInf2=0x7f7f7f7f7f7f7f7fLL;
const double dInf=1e15;
const double eps=1e-8;

u16 rnd16(){	return (u16)(rand())&MSK16;    }
u32 rnd32(){    return (((u16)(rand())&MSK16)<<16)|(rand()&MSK16);    }
uLL rnd64(){    return (((uLL)(rand())&MSK16)<<48)|(((LL)(rand())&MSK16)<<32)|(((u16)(rand())&MSK16)<<16)|(rand()&MSK16);    }
short rnd15(){    return rand()&MSK15;    }
int rnd31(){	return ((rand()&MSK15)<<16)|(rand()&MSK16);    }
LL rnd63(){    return (((LL)(rand())&MSK15)<<48)|(((LL)(rand())&MSK16)<<32)|((u32)(rand()&MSK16<<16))|(rand()&MSK16);    }
int rnd(){    return rnd31();    }
LL lrnd(){    return rnd63();    }

int a[10010];
int n;

LL check(int v)
{
	int maxn=0,cur=0;
	for(int i=1; i<=n+1; i++)
	{
		if(a[i]>=v) cur++;
		else maxn=max(maxn,cur), cur=0;
	}
//	cout<<v<<" "<<maxn<<endl;
	return 1LL*v*maxn;
}

int main()
{
    ios::sync_with_stdio(false);

	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];
	
	LL maxn=0;
	for(int i=1; i<=n; i++) maxn=max(maxn,check(a[i]));
	
	cout<<maxn<<endl;

    return 0;
}





















































