#include <iostream>
#include <fstream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <unordered_set>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecdouble vector<double>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define vec2pairll vector<vector<pair<long long,long long>>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)
#define forbit(s,a) for(int s = 0; s < (1 << a); s++)

#define INF 1000000000000
#define Pi 3.1415926535897932384626

ll gcd(ll a, ll b)
{
	if (min(a, b) == 0)
		return max(a, b);

	return gcd(min(a, b), max(a, b) % min(a, b));
}

ll lcm(ll a, ll b)
{
	ll buf = gcd(a, b);

	return abs(a * b) / buf;
}

string toBaseNum(ll n, ll base)
{
	string s;

	while (n > 0)
	{
		s = to_string(n % base) + s;
		n /= base;
	}

	return s;
}

int main() {
	ll n, m,k, ans = 0;
	string s = "No";
	bool flag = false;

	cin >> n;

	vecll a(n);

	forll(i, 0, a.size())
		cin >> a[i];

	vecpairll num(n);

	forll(i, 0, n)
	{
		num[i] = { a[i],1 };

		forll(j, i+1, n)
		{
			if (a[j] < num[i].first)
			{
				ans = max(ans, num[i].first * num[i].second);
				num[i].first = a[j];
			}

			num[i].second++;
		}

		ans = max(ans, num[i].first * num[i].second);
	}
	
	cout << ans << "\n";
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
		
	for(int l=1;l<=n;l++)
	{
		int x=a[l];
		for(int r=l;r<=n;r++){
		x=min(x,a[r]);
		ans=max(ans,x*(r-l+1));}
	}
	cout<<ans;
	return 0;
	}