#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e18;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}
ll ceilll(ll a, ll b) {return (a + b-1) / b;} // if(a%b != 0) (a/b) + 1
ll get_digit(ll a) {ll digit = 0; while(a != 0){a /= 10; digit++;} return digit;} // a != 0
template<typename T> void vecdbg(vector<T>& v){ rep(i, v.size()){cout << v[i] << " ";} br;}
template<typename T> void vecvecdbg(vector<vector<T>>& v){ rep(i, v.size()){rep(j, v[i].size()){cout << v[i][j] << " ";} br;}}
ll POW(ll a, ll n){ ll res = 1; while(n > 0){ if(n & 1){ res = res * a; } a *= a; n >>= 1; } return res; }
using P = pair<ll, ll>;

// 0 false, 1 true 
// string number to int : -48 or - '0'
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
// global vector -> 0 initialization
// DONT FORGET TO INTIALIZE
// The type of GRID is CHAR. DONT USE STRING
// If the result in local and judge is different, USE CODETEST!!
// (a * b)over flow?   if(a > INF / b){ /* overflow */}

struct UnionFind
{
    vector<long long> d;
    UnionFind(long long n = 0) : d(n, -1)
    {
    }

    //root : -size, not root: root
    long long root(long long x){
        if(d[x] < 0){
            return x; 
        }
        return d[x] = root(d[x]);
    }

    bool unite(long long x, long long y){
        x = root(x);
        y = root(y);
        if(x == y){
            return false;
        }
        if(d[x] > d[y]){
            swap(x, y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    long long size(long long x){
        return -d[root(x)];
    }

    bool issame(long long a, long long b){
        return root(a) == root(b);
    }
};

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    vector<long long> a(n);
    for(long long i = 0; i < n; i ++){
        cin >> a[i];
    }

    

    ll ans = INF;
    for(ll bit = 0; bit < (1<<(n-1)); bit++){
        UnionFind uf(n);
        vector<ll> tmp;
        //cout << "{ ";
        for(ll i = 0; i < (n-1); i++){
            
            if((bit>>i) & 1){
                tmp.push_back(i);
                //cout << i << " ";
            }
        }
        //cout << " }" << endl;

        for(ll i = 0; i < tmp.size(); i++){
            uf.unite(tmp[i], tmp[i]+1);
        }

        //cout << "uf ";
        vector<ll> res(n);
        for(ll i = 0; i < n; i++){
            ll x = uf.root(i);
            res[x] = res[x] | a[i];
            //cout << uf.root(i) << " ";  

        }

        ll now = 0;
        rep(i, n){
            now = now ^ res[i];
        }

        //cout << "now = " << now << endl;
        ans = min(ans, now);


    }

    cout << ans << endl;




}
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 20; int n;
lli a[maxN];

lli solve(int i = 0, lli currOr = 0, lli currXor = 0)
{
  if (i == n) return currXor ^ currOr;

  currOr |= a[i];
  lli ans = min(
    solve(i + 1, 0, currXor ^ currOr),
    solve(i + 1, currOr, currXor)
  );

  return ans;
}

int main()
{
  while (~scanf("%d", &n))
  {
    for (int i = 0; i < n; i++)
      scanf("%lld", &a[i]);

    lli ans = solve();
    printf("%lld\n", ans);
  }
  return 0;
}