#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
int main(void){
    // Your code here!
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 int i,j,ans,m,n;
 cin >> n;
 int a[n];
 for(i=0;i<n;i++)
 cin >> a[i];
 ans=0;
 for(i=0;i<n;i++)
 {
  m=INT_MAX;
  for(j=i;j<n;j++)
  {
   m=min(m,a[j]);
   ans=max(ans,(j-i+1)*m);
  }
 }
 cout << ans;
 return 0;
}
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define print(x) if(x)cout<<"YES\n";else cout<<"NO\n";
#define pb push_back
#define F first
#define S second
//#define mod 1000000007
#define mod 998244353
using namespace __gnu_pbds;
using namespace std;
void solve() {
	int n;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll res = (ll)1e14;
	for (int i = 0; i <= (1 << n); i++) {
		ll x = 0, ans = 0;
		for (int j = 0; j < n; j++) {
			if (j == 0) {
				x = a[j];
			}
			else {
				int curbit = ((i >> j) & 1);
				int lastbit = ((i >> (j - 1) & 1));
				if (curbit == lastbit) {
					x |= a[j];
				}
				else {
					ans ^= x;
					x = a[j];
				}
			}
		}
		ans ^= x;
		res = min(res, ans);
	}
	cout << res << "\n";
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	fastio;
	int T = 1;
	// cin>>T;
	while (T--) {
		solve();
	}
}