#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
long long A[10010];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
        scanf("%lld",&A[i]);

    long long ans=A[0];

    for(int i=0;i<N;i++)
    {
        long long minimum=A[i];
        for(int j=i;j<N;j++)
        {
            minimum=min(minimum,A[j]);
            ans=max(ans,minimum*(j-i+1));
        }
    }
    printf("%lld",ans);

    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define irep(i,a,b) for(int i=int(a);i<(int)b;++i)
#define rrep(i,a,b) for(int i=int(a);i>=(int)b;--i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll,ll>>>
#define vpl vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define pb push_back
#define se second
#define fi first
#define all(v) v.begin(),v.end()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>

using namespace std;

template<typename T> istream& operator>>(istream&i,v(T)&v){rep(j,v.size())i>>v[j];return i;}
template<typename T> string join(const v(T)&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T> ostream& operator<<(ostream&o,const v(T)&v){if(v.size())o<<join(v);return o;}



using ll = long long;
const ll INF = LLONG_MAX-1e9;
const double PI = acos(-1);

const ll mod = 1e9 + 7; //998244353;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll modpow(ll a,ll b){
    if(b == 0){
        return 1;
    }
    if(b%2 == 0){
        ll tmp = modpow(a,b/2);
        return tmp*tmp%mod;
    }else{
        return modpow(a,b-1)*a%mod;
    }

}

//区間最大値または最小値を求めるセグメント木の構造体

template <typename T>
struct RMQ {
    const T INF = numeric_limits<T>::max();
    T bound;  //最小値のときはinf,それ以外の時0となる
    int n;
    bool flag; //最大値でtrue
    vector<T> dat;
    RMQ(int n_,bool flag_ = true) : n(),flag(flag_), dat(n_ * 4,flag_ ? 0 : INF){
        int x = 1;
        while(n_ > x){
            x *= 2;
        }
        n = x;
        if(flag_){
            bound = 0;
        }else{
            bound = INF;
        }
    }

    T func(T a,T b){
        if(flag){
            return max(a,b);
        }else{
            return min(a,b);
        }
    }

    void update(int i,T x){
        i += n - 1;
        dat[i] = x;
        while(i > 0){
            i = (i-1)/2;
            dat[i] = func(dat[i*2+1],dat[i*2+2]);
        }
    }


    T query(int a,int b){
        return query_sub(a,b,0,0,n);
    }

    T query_sub(int a,int b,int k,int l,int r){
        if(r <= a || b <= l){
            return bound;
        }else if(a <= l && r <= b){
            return dat[k];
        }else{
            T v_l = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T v_r = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return func(v_l, v_r);
        }
    }


};

ll dp[10005][10005];

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;
    ll ans = 0;
    rep(i,n){
        int l = i,r = i;
        while(l >= 0){
            --l;
            if(a[l] < a[i] || l == -1){
                l++;
                break;
            }
        }
        while(r < n){
            r++;
            if(a[r] < a[i] || r == n){
                --r;
                break;
            }
        }
        
        ans = max(ans,a[i]*(r-l+1));
    }
    cout << ans << endl;
    return 0;
}
