#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;

    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int res = 2000000000;
    for (int i = 0; i < (1 << (n - 1)); i++)
    {
        int xored = 0;
        int ored = 0;
        for (int j = 0; j <= n; j++)
        {

            if (j < n)
                ored |= a[j];
            if (j == n || (i >> j & 1))
                xored ^= ored, ored = 0;
        }
        res = min(res, xored);
    }

    cout << res;
    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <numeric>
using namespace std;

using ll = long long;

#define For(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFor(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
#define co(a) cout<<a<<endl
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define cfs(a) cout<<fixed<<setprecision(a) 


int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	ll sum = 0;
	For(i, 0, N) {
		cin >> A[i];
	}
	if (N == 1) {
		co(A[0]);
		return 0;
	}
	vector<ll> temps(N);
	ll sep, temp;
	ll Min = 100000000000;
	For(i, 0, 1 << (N - 1)) {
		sep = 0;
		temp = 0;
		For(j, 0, (N - 1)) {
			if ((i >> j) & 1) {
				temps[j] = 0;
				For(k, sep, j + 1) {
					temps[j] |= A[k];
				}
				sep = j + 1;
				temp ^= temps[j];
				//co(i << " " << j << " " << temp << " " << temps[j]);
			}
			if (j == N - 2) {
				temps[j + 1] = 0;
				For(k, sep, N) {
					temps[j + 1] |= A[k];
				}
				temp ^= temps[j + 1];
				//co(i << " " << j << " " << temp << " " << temps[j]);
			}
		}
		Min = min(Min, temp);
	}
	co(Min);
}