#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);  
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  int max = -1;
  for(int l = 0; l < n; l++) {
    int min = a[l];
    for(int r = l; r < n; r++) {
      if(a[r] < min) {
        min = a[r];
      }
      if(min * (r - l + 1) > max) {
        max = min * (r - l + 1);
      }
    }
  }
  cout << max;
}


// code by lynmisakura. wish to be accepted!

#include<bits/stdc++.h>
using namespace std;

#define rep(i,N) for(int i = 0;i < N;i++)
#define rng(i,a,b) for(int i = a;i < b;i++)

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

#define lmd(func) auto func = [&]

#define mp make_pair
#define pb push_back
#define eb emplace_back

#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout<<"["<<#a<<","<<#b<<"] = "<<"["<<a<<","<<b<<"]\n"
#define debug3(a,b,c) cout<<"["<<#a<<","<<#b<<","<<#c<<"] = "<<"["<<a<<","<<b<<","<<c<<"]\n"
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
    cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
    return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
    cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
    return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
    cout << "{" << p.first << "," << p.second << "}" << '\n';
    return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
    for (auto& i : arr)cin >> i; return in;
}
template<class S,class T> istream &operator >> (istream& in,pair<S,T>& p){
    cin >> p.first >> p.second; return in;
}

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;

/////////////////////////////////////////////////////////////////////////////

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(20);
  
  int ans = INT_MAX;

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

  rep(mask,(1<<(n-1))){
    int cand = 0;
    int tmp = 0;
    rep(i,n){
      tmp |= a[i];
      if(i < n-1 && (mask >> i & 1)){
        cand ^= tmp;
        tmp = 0;
      }
    }
    cand ^= tmp;
    ans = min(ans , cand);
  }

  cout << ans << '\n';

}
