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

#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define dep(i, r, l) for (int i = r; i >= l; --i)

const int mod = 1e9 + 7;

void read (int &x) {
	x = 0; char c = getchar();
	while(c < '0' || c > '9') c = getchar();
	while(c >= '0' && c <= '9')
		x = x * 10 + c - 48, c = getchar();
}

namespace Mint {
	struct mint {
		int x ;
		mint(int _x = 0) { x = _x ; }
		mint operator = (int _x) { return mint(x = _x); }
	};
	inline mint operator * (mint a, mint b) { return 1ll * a.x * b.x % mod ; }
	inline mint operator - (mint a, mint b) { return ((a.x -= b.x) < 0) ? a.x + mod : a.x ; }
	inline mint operator + (mint a, mint b) { return ((a.x += b.x) >= mod) ? a.x - mod : a.x ; }
	inline mint Pow(mint a, int b) { mint r = 1; while(b) { if(b & 1) r = r * a; a = a * a, b >>= 1; } return r; }
	inline mint operator / (mint a, mint b) { return a * Pow(b, mod - 2); }
	inline bool operator == (mint a, mint b) { return a.x == b.x; }
	ostream& operator << (ostream& out, mint b) { out << b.x; return out; }
}

int n, a[21], Lim, ans = 0x7fffffff;

int main () {

	scanf("%d", &n), Lim = 1 << n - 1; 
	rep(i, 1, n) read(a[i]);
	
	dep(dev, Lim - 1, 0) {
		int now = 0, sum = 0;
		rep(i, 1, n) {
			now |= a[i];
			if (dev & (1 << i - 1))
				sum ^= now, now = 0;
		}
		sum ^= now, ans = min(ans, sum);
	}
	
	printf("%d", ans);

	return 0;
}

// Problem: C - ORXOR
// Contest: AtCoder - AtCoder Beginner Contest 197（Sponsored by Panasonic）
// URL: https://atcoder.jp/contests/abc197/tasks/abc197_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int MOD = 1e9 + 7;
//const int ULTRA = 1e14;
const int PROMAX = 1e6 + 5;
const int PRO = 1e5 + 5;

#define ll long long
#define int ll
#define all(x) x.begin(), x.end()
#define lla(x) x.rbegin(), x.rend()
#define pb push_back
#define ThinkTwice ios_base::sync_with_stdio(false); cin.tie(NULL);
int    dx[] = {-1,  0,  1,  0, -1, -1,  1,  1};
int    dy[] = { 0,  1,  0, -1, -1,  1,  1, -1};
char  dir[] = {'U','R','D','L'};
inline int powmod(int a, int b, int mod) {int res=1; while(b>0) {if(b&1) res=(res*a)%mod; a=(a*a)%mod; b>>=1; } return res;}
inline int power(int a, int b) {int res=1; while(b>0) {if(b&1) res*=a; a*=a; b>>=1;} return res; }
//__________________________________________________________________


void solve() {
    int n; cin>>n;
    int a[n];
    for(int i = 0; i<n; i++) cin>>a[i];
    int res = 0;
    for(int i = 0; i<n; i++) res ^= a[i];
    for(int mask = 0; mask < (1<<n); mask++) {
    	vector <int> dp;
    	for(int bit = 0; bit<n; bit++) {
    		if(mask & (1<<bit)) dp.pb(1);
    		else dp.pb(0);
    	}
    	int k = dp[0], tmp = 0, tmp_xor = 0;
    	for(int i = 0; i<n; i++) {
    		if(dp[i] == k) {
    			tmp |= a[i];
    		}
    		else {
    			tmp_xor ^= tmp;
    			tmp = a[i];
    		}
    	}
    	tmp_xor ^= tmp;
    	res = min(res, tmp_xor);
    }
    cout<<res<<endl;
}

signed main() {
	ThinkTwice
	int t;
	
	t = 1;
	// cin>>t;

	for(int i = 1; i<=t; i++) {
		// cout<<"Case #"<<i<<": ";
		solve();
	}
}

//__________________________________________________________________
/*
Sample Input:


Sample Output:


*/
