#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

class smart_sieve {
  intmax_t L, R, M;
  std::vector<int> small;  // 小さい篩
  std::vector<std::vector<intmax_t>> large;  // 大きい篩
  std::vector<intmax_t> aux;  // aux[i] := large[i] の素因数の積

public:
  smart_sieve(intmax_t L, intmax_t R): L(L), R(R), M(sqrt(R)+1) {
    small.resize(M);
    std::iota(small.begin(), small.end(), 0);
    large.resize(R-L);
    aux.assign(R-L, 1);

    for (intmax_t i = 2; i*i < R; ++i) {
      if (small[i] < i) continue;
      small[i] = i;
      for (intmax_t j = i*i; j < M; j += i)
        if (small[j] == j) small[j] = i;

      for (intmax_t j = (L+i-1)/i*i; j < R; j += i) {
        intmax_t k = j;
        do {
          // aux[j-L] > M で判定した方がいいかも？
          // j / aux[j-L] < M の方がいい？（割り算したくない）
          if (aux[j-L] * aux[j-L] > R) break;

          large[j-L].push_back(i);
          aux[j-L] *= i;
          k /= i;
        } while (k % i == 0);
      }
    }
  }

  std::vector<intmax_t> factor(intmax_t n) {
    assert(L <= n && n < R);
    std::vector<intmax_t> res = large[n-L];
    n /= aux[n-L];
    if (n >= M) {
      // この場合，n は素数となることが示せる（はず）
      // n*n >= R だとオーバーフローしそう？
      res.push_back(n);
      return res;
    }
    while (n > 1) {
      res.push_back(small[n]);
      n /= small[n];
    }
    return res;
  }
};

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n+n);
  rep(i,n)cin >> a[i];
  ll m=99999999999999999,p,j,k;
  for (ll bit = 0; bit < (1<<n); ++bit) {
    p=0;
    j=0;
    k=0;
    b[0]=0;
        for (ll i = 0; i < n; ++i) {
            if (bit & (1<<i)){ // 列挙に i が含まれるか
              j++;
              b[j]=a[i];
            }
            else{
              b[j]=b[j]|a[i];
            }
        }
    for (ll i = 0; i < j+1; ++i) {
      p=p^b[i];
    }
    if(m>p)m=p;
  }
  cout << m << endl;
}
#include <iostream> 
#include <vector>
#define int long long
using namespace std;
const int N = 30;
typedef long long LL; 
int n;
LL seq[N];
signed main(){
	#ifndef ONLINE_JUDGE
		freopen("tpl.txt","r",stdin);
#endif
	cin >> n;
	for(int i = 0; i < n; i ++) cin >> seq[i];
	int ans = 0x7f7f7f7f;
	for(int i = 0; i <= (1 << n) -1; i ++){
		vector<LL > vc;
		
		for(int j = i  ,l = 0 , r = 0; r != n ;j >>= 1,  r ++){
			int t = 0;	
			if( j & 1 == 1 || r == n-1){
				t = seq[l];
				while(l <= r){
					//cout << seq[l]  << ' ';
					t |= seq[l];
					l++;
				}
				vc.push_back(t);
			}
		}
		//cout << endl;
		
		int tt = vc[0];
		for(int k = 1; k < vc.size();k++){
			tt ^= vc[k];
		}
		ans = min(tt,ans);
	}
	int t = 0;
	for(int i = 0; i < n; i ++){
		t ^= seq[i];
		//cout << seq[i] << ' ';
	}
	//cout << endl;
	ans = min(t,ans);
	cout << ans << endl;
	
}