#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1> 
void pr(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1> 
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1> 
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }

#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
#define PI pair<int,int>
template<typename T1> 
T1 gcd(const T1 &a, const T1 &b) {
    if (a == 0 || b == 0) return a + b;
    return gcd(b, a %b);
}
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 200001 
#define MOD 998244353

int N[21];
int bx, n;

void comb(int i, int xr, int x) {
    if (i == -1) {
        chmin(bx, x ^ xr);
        return;
    }
    if (x > 0) comb(i-1, xr ^ x, N[i]);
    comb(i-1, xr, x | N[i]);
}


void solve() {
    cin >> n;
    rep(i,n) cin >> N[i];
    bx = INT_MAX;
    comb(n-1,0,0);
    out(bx);
}
 
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
#ifdef _OLIMPOLOCAL
    cin >> test;
#endif
    rep(testCase, test) {
        solve();
    }
    return 0;
}
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
#define maxn 3e5+50

using namespace std;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

const ll mod = 1e9+7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;


void solve(){
    int n;cin >> n;
    vector<int>a(n);
    for(int i = 0;i<n;i++) cin >> a[i];
    int ans = INT_MAX;
    int start = a[0];
    for(int mask = 0;mask<(1<<(n-1));mask++){
        int tp = start;
        int tp2 = mask;
        int cnt = 1;
        vector<int>b;
        while(tp2){
            if(tp2%2){b.push_back(tp);tp = a[cnt];}
            else tp |= a[cnt];
            cnt++;tp2 /= 2;
        }
        for(int  i = cnt;i<n;i++) tp |= a[i];
        b.push_back(tp);
        int now = b[0];
        for(int i = 1;i<b.size();i++) now ^= b[i];
        ans = min(ans,now);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   // freopen("shuffle.in","r",stdin);
   // freopen("shuffle.out","w",stdout);
    solve();
    return 0;
}
