#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// inline ll hhme(ll a, ll b){
//     return 300005LL * a + b;
// }
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash {
//     int operator()(int x) const { return x ^ RANDOM; }
// };
//gp_hash_table<ll, ll, chash> mpp;
#define eb emplace_back
using ll = long long;
const int inf = 1e9+5;
const ll INF = 1e18+5;
const int nax = 2e5+500;
//#define int long long
bool ip(int n) {
	for(int i=2;i<=sqrt(n);i++) {
		if(n % i == 0) return 0;
	}
	return 1;
}
int32_t main() {
	//freopen("g:/coding/cpp/input.txt","r",stdin);
	//freopen("g:/coding/cpp/output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	map<int,int> occur;
	for(int i=2;i<=n;i++) {
		map<int,int> f;
		int num = i;
		for(int j=2;j<=i;j++) {
			if(num == 1) break;
			while(num > 1 && num % j == 0) {
				num /= j;
				f[j]++;
			}
		}
		for(auto it:f) {
			occur[it.first] = max(it.second, occur[it.first]);
		}
	}
	ll ans = 1;
	for(auto it:occur) {
		ans *= pow(it.first, it.second);
	}
	ans++;
	debug()<<imie(ans);
	for(int i=2;i<=n;i++) assert(ans % i == 1);
	cout << ans;
}

#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fs first
#define sd second
#define rept(i,n) for(ll i=0;i<n;i++)
#define rrept(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define mpit map<ll,ll>::iterator
#define stit set<ll,ll>::iterator
#define quit queue<ll,ll>::iterator
#define maxt(a,b,c) max(a,max(b,c))
#define mint(a,b,c) min(a,min(b,c))
#define rsort(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define prnt(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";
using namespace std;
typedef long long int ll;
void solve()
{
   ll n;
   cin>>n;
   ll a[n];
   for(ll i = 0;i<n;i++)
    cin>>a[i];
   ll val = 0;
   for(ll i = 0;i<n;i++)
   {
       ll mini = a[i];
       for(ll j = i;j<n;j++)
       {
           mini = min(mini,a[j]);
           val = max(val,(j-i+1)*mini);
       }
   }
   cout<<val<<"\n";
}
int main()
{
    speed;
    ll t=1;
    //cin>>t;
    while(t--)
    {
         solve();
    }
    return 0;
}
