/* OVERKILLED */


// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,sse,sse2")


#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include<climits>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <chrono>
using namespace std;
#define ld long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
const int inf = LLONG_MAX;

#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
//int const mod = 998244353;
int const mod = 1e9 + 7;
int const hashmod = 1610612741;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */

struct cmp
{
	bool operator() (pair<int, int> a, pair<int, int> b) {

		return a.r > b.r;


	}
};

int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2) % mod;
}

int fact[400005];

void fact_pre() {
	fact[0] = 1;
	for (int i = 1; i <= 400000; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}
}

int ncr(int n, int r) {
	if (r > n) return 0;
	int a = fact[n];
	a *= modinv((fact[n - r] * fact[r]) % mod);
	return a % mod;
}


int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp1(pii a, pii b) {
	return a.l > b.l;
}

bool comp2(pair<pii, int> a, pair<pii, int> b) {

	if (a.l.l == b.l.l)
		return a.r < b.r;

	return (a.l.l < b.l.l );
}
bool comp(string a, string b) {

	return a[0] > b[0];
}
#define nax   10000005

int t1 = 0;



void go() {
	int n;
	cin >> n;
	int arr[n];
	int ans = inf;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int pre[n];
	pre[0] = arr[0];
	for (int i = 1; i < n; i++) {
		pre[i] = pre[i - 1] | arr[i];
	}
	for (int i = 0; i < (1 << n); i++) {
		int cn = i;
		vector<int> v(n, 0);
		int cx = 0;
		int cn1 = 0;
		for (int j = 0; j < n; j++) {
			if (((i >> j) & 1) == 1)
			{
				v[j] = 1;
			}
		}
		for (int j = 0; j < n; j++) {
			if (v[j] == 1) {
				cn1 |= arr[j];
				cx ^= cn1;
				cn1 = 0;
			}
			else {
				cn1 |= arr[j];
			}
		}
		cx ^= cn1;
		ans = min(ans, cx);

	}
	cout << ans;








}




signed main() {


	haha
	int t;
	t = 1;


	while (t--) {

		go();
	}


}
#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

template<typename T>
void printArray(vector<T> &printVec) {
    if(printVec.empty()) return;
    cout << printVec[0];
    for(int i = 1; i < printVec.size(); ++i) cout << " " << printVec[i];
    cout << endl;
}

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL res = LINF;
void dfs(vector<LL> &v, int pos, LL val, LL xo) {
    if(pos == v.size()) {
        res = min(res, xo ^ val);
        return;
    }

    dfs(v, pos + 1, val | v[pos], xo);
    xo ^= val;
    dfs(v, pos + 1, v[pos], xo);

    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N;
    cin >> N;
    vector<LL> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
    }

    dfs(v, 0, 0, 0);
    cout << res << endl;
    return 0;
}

