#include <iostream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <limits>
#include <queue>
#include <algorithm>
using namespace std;

using ull = unsigned long long;
using ui = unsigned int;

int res;
void bs(const vector<int>& nums, int idx, int prexor) {
    int size = nums.size();
    if(idx == size) {
        // todo
        res = min(res, prexor);
        return;
    }
    int now_or = 0;
    for(int i = idx; i < size; i++) {
        now_or |= nums[i];
        bs(nums, i + 1, prexor ^ now_or);
    }
}


void func() {
    int N;
    cin >> N;
    vector<int> nums;
    for(int i = 0; i < N; i++) {
        int v;
        cin >> v;
        nums.push_back(v);
    }
    res = INT32_MAX;
    bs(nums, 0, 0);
    cout << res << endl;
}


int main() {
    func();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<vector<vector<long double> > > vvvld;
typedef vector<vector<long double> > vvld;
typedef vector<vector<vector<int> > > vvvi;
typedef vector<vector<int> > vvi;
typedef long double ld;

#define rep(i,n) for (int  i = 0; i< (int)(n); i++)
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  vector<bitset<30>> bi;
  for(int i =0; i<n; i++){
    cin>>a.at(i);
    bitset<30> bb(a.at(i));
    bi.push_back(bb);
  }
  ll lans =1e18;
  for(int i =0; i<(1<<n-1); i++){
    bitset<20> b(i);
    queue<bitset<30>> q;
  vector<bitset<30>> bt = bi;
    for(int j =0; j<n-1; j++){
      if(b.test(j)){
	q.push(bt.at(j));
      }
      else{
	bt.at(j+1) = bt.at(j+1)|bt.at(j);
      }
    }
    q.push(bt.at(n-1));
    bitset<30> ans;
    ans = q.front();q.pop();
    while(!q.empty()){
      bitset<30> tmp = q.front();q.pop();
      ans = ans^tmp;
    }
    ll ltmp = 0;
    ll two = 1;
    for(int i =0; i<30; i++){
      if(ans.test(i)) ltmp += two;
      two*=2;
    }
    lans = min(ltmp,lans);
  }
  cout<<lans<<endl;
}
