#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void Main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        int m = a[i];
        rep(j, i+1, n+1) {
            chmin(m, a[j-1]);
            chmax(ans, m*(j-i));
        }
    }
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // int t; cin >> t; rep(i, t)
    Main();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define pb push_back
#define eb emplace_back
const long long  Max = 1e5+10;
const int Mod = 1e9 + 7;
int main()
{

    fastread();

    ll n;

    cin>>n;

    ll ara[n+2];

    ll mx=0;

    for(ll i=0; i<n; i++)
    {
        cin>>ara[i];

    }


    for(ll i=0; i<n; i++)
    {
        ll cnt=0,j=i;

        while(j<n && ara[j]>=ara[i])
        {
            cnt++;
            j++;
        }

        j=i-1;


        while(j>=0 && ara[j]>=ara[i])
        {
            cnt++;
            j--;
        }

        cnt*=ara[i];

        mx=max(mx,cnt);
    }

    cout<<mx<<endl;






}
