#include <bits/stdc++.h>
using namespace std;

int ans;
int A[25];

void solve(int pos, int currOr, int currXor)
{
    if (pos < 0)
    {
        ans = min(ans, (currOr ^ currXor));
        return;
    }
    
    solve(pos-1, (currOr | A[pos]), currXor);
    solve(pos-1, A[pos], (currXor ^ currOr));
}

int main() {
    
    int n;
    cin >> n;
    
    for (int i=0; i<n; i++)
        cin >> A[i];
    
    ans = (1 << 30);
    
    solve(n-1, 0, 0);
    
    cout << ans << "\n";
    return 0;
}

#include <iostream>
#include <vector>
#include <climits>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int res = INT_MAX;

    rep(bit, (1<<(n-1))){
        vector<int> buf(n, 0);
        int count = 0;
        buf.at(count) = a.at(0);
        for(int j = 0; j < n-1; j++){
            if(bit & (1<<j)) count++;
            buf.at(count) |= a.at(j+1);
        }
        int xo = 0;
        rep(i, n) xo ^= buf.at(i);
        res = min(res, xo);
    }

    cout << res << endl;

}