#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep(i, N) cin >> A[i];
  long ans = 0;
  rep(i, N) {
    long C = 1000000;
    for(int j = i; j < N; j++) {
      C = min(C, A[j]);
      ans = max(ans, C*(j+1-i));
      
    }
  }
  cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define ff first
#define ss second
#define double long double
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define dbg(x) cout << "~~~~~" << #x << "--->" << x << endl;
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define sz(a) ((int)(a).size())
#define setbit(n) (__builtin_popcount(n))
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
const int inf = 1e10 + 7;
const double eb=1e-9;
const int mod = 1e9 + 7;
template <class T>
T add(T v1,T v2, int mo=mod)
{
    return (v1%mo + v2%mo)%mo;
}
template<class T>
T subtract(T v1,T v2,int mo=mod)
{
    return (v1%mo - v2%mo)%mo;
}
template<class T>
T mult(T v1, T v2,int mo=mod)
{
    return (v1%mo * v2%mo )%mo;
}
template<class T,class P>
void build_st(vector<T> &a,vector<P> &segT,int start,int end,int tidx)
{
    if(start==end)
    {
    	segT[tidx]=a[start];
    	return;
    }
    int mid=start+(end-start)/2;
    build_st(a,segT,start,mid,tidx*2);
    build_st(a,segT,mid+1,end,2*tidx+1);
    
    segT[tidx]=segT[tidx*2]+segT[tidx*2+1];
}
template<class T,class P>
void update_st(vector<T> &a,vector<T> &segT,int start,int end,int tidx,int idx,T val)
{
    if(start==end)
    {
    	segT[tidx]=a[idx]=val;
    	return;
    }
    int mid=start+(end-start)/2;
    if(idx>mid)
    	update_st(a,segT,mid+1,end,2*tidx+1,idx,val);
    else
    	update_st(a,segT,start,mid,2*tidx,idx,val);
    segT[tidx]=segT[2*tidx]+segT[2*tidx+1];
}
template<class T>
T query_st(vector<T> &segT,int start,int end,int tidx,int left,int right)
{
    if(start>right || end<left)
    	return 0;
    if(start>=left && end<=right)
    	return segT[tidx];
    int mid=start+(end-start)/2;
    T val1=query_st(segT,start,mid,2*tidx,left,right);
    T val2=query_st(segT,mid+1,end,2*tidx+1,left,right);
    return val1+val2;
}
template <class T>
void in(vector<T> &a, int n, int g = 0)
{
    for (int i = g; i < n + g; i++)
        cin >> a[i];
}
template <class T>
void pv(vector<T> &a)
{
    for (auto i : a)
        cout << i << " ";
    cout << endl;
}
template <class T>
void pvv(vector<vector<T>>&a)
{
	for(auto i:a)
	{
		for(auto j:i)
			cout<<j<<" ";
		cout<<endl;
	}
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

void solver()
{
    int n;cin>>n;
    vi a(n);
    in(a,n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
    	int mn=inf;
    	for(int j=i;j<n;j++)
    	{
    		mn=min(mn,a[j]);
    		ans=max(ans,(j-i+1)*mn);
    		// dbg(mn);
    	}
    }
    cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(15);
    
    int t = 1;
    // cin>>t;
    while (t--)
    {
        solver();
    }
}
