#include<bits/stdc++.h>
using namespace std;
#define _ 0
const long long maxn=1e5+5;
const long long inf=0x7fffffff;
long long n,a[maxn],minv=inf;
void dfs(long long k,long long s1,long long s2)
{
	if(k==n+1)
	{
		minv=min(minv,s1^s2);
		return ;
	}
	dfs(k+1,s1|a[k],s2);
	dfs(k+1,a[k],s1^s2);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin>>n;
    for(long long i=1;i<=n;i++)
    	 cin>>a[i];
    dfs(0,0,0);
    cout<<minv<<endl;
	return ~~(0^_^0);
}

/**
 *  author: MKutayBozkurt
 *  created: 01.04.2021 08:26:08
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int N; cin >> N;
  vector<long long> A(N); for (auto &x : A) cin >> x;
  long long ans = 1e18;
  for (int i = 0; i < (1 << N); i++) {
    long long ored = 0, xored = 0;
    for (int j = 0; j < N; j++) {
      int k = i & (1 << j);
      ored |= A[j];
      if (k) {
        xored ^= ored;
        ored = 0;
      }
    }
    xored ^= ored;
    ans = min(ans, xored);
  }
  cout << ans << '\n';
}
