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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cout << #x << ": " << x << "\n"
#define out(x) cout << x << endl

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n)cin >> a[i];
  
    if (n == 1) {
        cout << a[0] << endl;
        return 0;
    }

    ll min = LINF;
    int num = a.size() - 1;
	for (int bit = 1; bit < (1 << num); ++bit)
    {
        int j = 1;
        ll orp = a[0];
        vector<ll> xorp;
        for(int i = 0;i < num;i++){
            bool f = (bit & (1 << i)) ;
            if(f == 0){
				orp |= a[j];
            }else if(f == 1){
                xorp.emplace_back(orp);
                orp = a[j];
            }
            j++;
        }
        xorp.emplace_back(orp);

        ll xorpp = xorp[0];
        for(int i = 1;i<xorp.size();i++){
            xorpp ^= xorp[i];
        }

        chmin(min,xorpp);
        if(min == 0)break;

	}

    cout << min << endl;
    return 0;
}

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

#define int long long 

int n, a[21] ; 

int fun(int idx, int orr, int xr) {
    if (idx > n) {
        return (xr^orr) ; 
    }
    int cur = fun(idx+1, orr|a[idx], xr) ; 
    cur = min(cur, fun(idx+1, a[idx], xr^orr)) ; 
    return cur ; 
}

signed main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0); 

    cin >> n ; 
    for (int i=1;i<=n;++i) cin >> a[i] ; 
    int ans = fun(1, 0, 0) ; 
    cout << ans << endl ; 
    return 0;
}

