#include <bits/stdc++.h>
#define rep(i,N) for(int i=0; i<(N); i++)
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a.at(i);
  
  int ans=1<<30;
  rep(s,1<<(N-1)){
    int o=0;
    int now=0;
    rep(i,N){
      o |= a.at(i);
      if(s>>i&1){
        now ^= o;
        o = 0;
      }
    }
    now ^= o;
    ans = min(ans,now);
  }
  cout << ans << endl;
}
#include <bits/stdc++.h>
#define endl '\n'
#define umap unordered_map
#define all(var) var.begin(), var.end()
#define input freopen("input", "r", stdin)
#define output freopen("output", "w", stdout)
#define Fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define dbg(x) cerr << #x << " => " << x << endl
using Long = long long;
using namespace std;

signed main () {
    Fast;
    int n; cin >> n;
    int arr[n]; for (int &i: arr) cin >> i;

    vector<int> sets;

    auto calc = [&] (vector<int>& v) {
        int i = 0, idx = 0, Xor = 0;
        while (idx < (int)v.size()) {
            int Or = 0;
            while (i < v[idx]) Or |= arr[i++];
            Xor ^= Or;
            idx++;
        }
        return Xor;
    };
    int ans = INT_MAX;
    for (int i = 1; i <= (1 << (n - 1)); i++) {
        for (int j = 0; j < n - 1; j++) {
            if (i & (1 << j)) {
                sets.push_back(j + 1);
            }
        }
        sets.push_back(n);
        ans = min(ans, calc(sets));
        sets.clear();
    }
    cout << ans << endl;
}
