///                          BISMILLA HIRRAHMANIR RAHIM
///                              ALLAH IS ALMIGHTY
///                          ALLAH IS MUCH MORE CREATIVE

#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb              push_back
#define ff              first
#define ss              second
#define mem(a,v)        memset(a, v, sizeof(a))
#define all(a)          (a).begin(), (a).end()
#define pii             pair<ll,ll>
#define ci(X)                cin>>X
#define cii(X, Y)            cin>>X>>Y
#define ciii(X, Y, Z)        cin>>X>>Y>>Z
#define ciiii(W, X, Y, Z)    cin>>W>>X>>Y>>Z
#define co(x)                cout << x<< "\n"

#define rep(i,n)        for(int i = 0; i < (n); ++i)
#define rep1(i,n)       for(int i = 1; i <= (n); ++i)
#define dbg(x)          cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y)       cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z)     cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<" "<<#z<<"="<<(z)<<endl;
#define pq              priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;
using ll =                   int64_t;
using ii=                    pair<ll,ll>;
const double PI =            acos(-1.0);
const int mx =               2e5+5;
const int M=                 1e9+7;


int dr[]= {0,-1,0,1,-1,-1,1,1};  /// first 4 are right,up,left,bottom
int dc[]= {1,0,-1,0,1,-1,-1,1};
int kx[]= {-1,-2,-2,-1,1,2,2,1};  /// knight move
int ky[]= {2,1,-1,-2,-2,-1,1,2};

bool valid(int row,int col){
    return (row>=1) && (row<=8) && (col>=1) && (col<=8);
}

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b, a % b);
}

bool sq(ll x){
   ll y= sqrt(x);
   if(y*y==x) return true;
   return false;
}


void Solve()
{
    ll i,j,x,y,z,sum=0,ans=0,n,m=0,k=0,l=0,p=0,q=0;
    cin>>n;
    ll a[n+2];
    rep(i,n) cin>>a[i];
    vector<ll>b; ll mini= 1e18;

    for(i=0; i<(1<<(n-1)); i++){      /// (1 <<(n-1)) why??  can't understand;
        ll total=0;
        for(j=0; j<n; j++){          /// all possible subset
            total= total | a[j];
            if(i & (1<<j)){
               b.pb(total);    //dbg2(total,i);
               total=0;
            }
        }
        if(total) b.pb(total);
        ll cal=0;
        for(j=0; j<b.size(); j++)
            cal= cal ^ b[j];

     b.clear();
        mini= min(mini,cal);
    }
    cout<< mini<< "\n";

    return;
}

int main()
{
    faster;

   int TC=1;

    //cin >> TC;

    while(TC--){
         Solve();
    }

    return 0;
}
/**

*/

#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A[i];
  ll ans = 1LL << 40;
  for (ll x = 0; x < (1LL<<(N-1)); x++) {
    ll y = x | (1LL<<(N-1));
    ll val = 0;
    ll cur = 0;
    for (ll i = 0; i < N; i++) {
      cur |= A[i];
      if ((y >> i) & 1) {
        val ^= cur;
        cur = 0;
      }
    }
    ans = min(ans, val);
  }
  cout << ans << endl;

  return 0;
}

