#define _DEBUG
#include "bits/stdc++.h"
//#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug_6(x1,x2,x3,x4,x5,x6) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<", "#x6<<": "<<x6<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_6,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define prind(argument) cout<<std::fixed<<setprecision(13)<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define puba(a) emplace_back(a)
#define pubamp(a,b) emplace_back(mp(a,b))
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int A[21];
	scan(N);
	rep(i,N) scan(A[i]);
	ll ans=INFl;
	int bitall=(1<<(N-1));
	rep(bit,bitall){
		ll xo=0;
		int now=A[0];
		rep(i,N-1){
			if(bit&(1<<i)){
				xo^=now;
				now=A[i+1];
			}
			else{
				now|=A[i+1];
			}
		}
		xo^=now;
		chmin(ans,xo);
	}
	prin(ans);
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <set>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
using Interval = pair<ll,ll>;
using Graph = vector<vector<ll> >;
#define fi first
#define se second

struct Edge{
    ll to;
    ll w;
    Edge(ll to, ll w):to(to),w(w){}
};

using wGraph = vector<vector<Edge> >;


template<class T> void chmax(T& a, T b){
    if (a < b){
        a=b;
    }
}

template<class T> void chmin(T& a, T b){
    if (a > b){
        a=b;
    }
}

template<class T> bool chmaxb(T& a, T b){
    if (a < b){
        a=b;
        return true;
    }
    return false;
}

template<class T> bool chminb(T& a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

const ll INF = 1LL << 60;

ll n;
vector<ll> a(25);
vector<vector<ll> > OR(25,vector<ll>(25,0));

int main(){
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }

    rep(i,n){
        repi(j,i+1,n+1){
            ll tmp = 0;
            repi(k,i,j){
                tmp |= a[k];
            }
            OR[i][j] = tmp;
        }
    }


    ll ans  = INF;

    for (ll bit = 0; bit < 1<<(n-1);bit++){
        vector<ll> interval;
        interval.push_back(0);
        for (ll i = 0; i<n-1; i++){
            if (bit & (1<<i)){
                 interval.push_back(i+1);
            }
        }
        interval.push_back(n);

        ll res = -1;

        rep(i,interval.size()-1){
            ll l = interval[i];
            ll r = interval[i+1];
            if (res == -1){
                res = OR[l][r];
            }
            else{
                res ^= OR[l][r];
            }
        }

        ans = min(ans,res);

    }

    cout << ans << endl;

    return 0;
}