#include<bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define int ll
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define viii vector<vii>
#define vpi vector<pii>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf 1e9
#define minf -1e9
#define dd double
#define fori(i,x,n) for(ll i=x;i<=n;i++)
#define umap unordered_map<ll,ll>
#define mmap map<ll,ll>
#define mm 998244353
#define mod2 1000000009
#define br cout<<"\n"

// typedef tree<pii,null_type,less<pii>,rb_tree_tag,
// tree_order_statistics_node_update>PBDS;
ll n;
vi a;

map<pair<pii, ll>, ll>dp;

ll fun(ll i, ll orval, ll xorval) {
	if (i == n)return (xorval ^ orval);

	if (dp.count({{orval, xorval}, i}))return dp[ {{orval, xorval}, i}];

	return dp[ {{orval, xorval}, i}] = min(fun(i + 1, orval | a[i], xorval), fun(i + 1, a[i], xorval ^ orval));
}


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t;
	t = 1;
	// cin >> t;
	fori(test, 1, t) {

		cin >> n;

		a.resize(n);

		fori(i, 0, n - 1)cin >> a[i];





		cout << fun(0, 0, 0);

	}


	return 0;
}
#include<stdio.h>
#include<queue>
#define INF 1000000000000007
#define int long long
using namespace std;
struct pr{
	int now;
	int data;
};
int a[25];
queue<pr> q;
signed main(){
	int n,ans=INF;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	pr x;x.data=0;x.now=1;
	q.push(x);
	while(!q.empty()){
		x=q.front();q.pop();
		if(x.now>n){
			if(x.data<ans) ans=x.data;
          //hello,thank you
			continue;
		}
		int sum=x.data;
		int ths=x.now;
		int r=0;
		for(int i=ths;i<=n;i++){
			r|=a[i];
			pr y;y.data=sum^r;y.now=i+1;
			q.push(y);
		}
	}
	printf("%lld",ans);
	return 0;
} 