#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (long long i = (s); i < (long long)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    vector<int> a;
    a.resize(n);
    for(auto & x: a) cin >> x;

    int res = 0;

    rep(l, n){
        int minim = a[l];
        rep2(r, l, n){
            minim = min(minim, a[r]);
            res = max(res, minim * (int)(r-l+1LL));
        }
    }

    cout << res << endl;
    return 0; 
}
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x.begin(),x.end())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define endl "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define sz(a) (int)a.size()
#define Q(x) for(int i=0;i<x;i++)
#define show(x) for(auto i:x)cout<<i<<" ";cout<<endl;
// ctrl + shift + q -- stop execution
const ll mod = 1e9 + 7;
using namespace std;


void solve() {

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	/*int t;
	cin >> t;
	while (t--) {
		solve();
	}*/
	/*int n, ans = -1;
	double x;
	cin >> n >> x;
	double tot = 0;
	bool flag = false;
	rep(i, 0, n) {
		double a, b;
		cin >> a >> b;
		tot = tot + (a * (b / 100));
		if (tot > x && flag == false) {
			ans = i + 1;
			flag = true;
		}
	}
	deb(tot);
	cout << ans << endl;*/

	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n)cin >> a[i];

	ll ans = n * (*min_element(a.begin(), a.end()));
	//deb(ans);
	for (int i = 0; i < n; i++) {
		int area = 1;
		for (int j = i + 1; j < n; j++) {
			if (a[j] >= a[i])area++;
			else break;
		}
		for (int k = i - 1; k >= 0; k--) {
			if (a[k] >= a[i])area++;
			else break;
		}
		ll tempans = area * a[i];
		ans = max(ans, tempans);
	}
	cout << ans << endl;

	return 0;
}