//https://oeis.org/search?q=0%2C0%2C1%2C2%2C4%2C6&language=english&go=Search
//https://smallpdf.com/result#r=dc43c99933feaa1c7f3a2f2e2036bc6a&t=pdf-to-word
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <string.h>
using namespace std;
#define ll long long
#define INF 1000007
#define MAX 500007
#define nl "\n"
#define F first
#define S second
typedef vector<ll> vi;
typedef priority_queue<ll , vector<ll> , greater<ll> > pqmx;
typedef priority_queue<ll> pqmn;
typedef pair<ll , ll> pi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector< pair<int , int> > vpi;
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define yeS(GOOD)      GOOD ? cout<<"YES\n" : cout<<"NO\n"
#define all(a) a.begin() , a.end()
#define pb push_back
#define ar array
ll mod = LLONG_MAX;
ll binpow(ll a, ll b){ll res=1;a%=mod;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
ll binmul(ll a, ll b){ll res=0;a%=mod;while(b>0){if(b&1)res=(res + a)%mod;a=(a + a)%mod;b>>=1;}return res;}
ll area(pi a, pi b,pi c){return abs(a.F * b.S + b.F * c.S + c.F*a.S - a.S * b.F - b.S * c.F - c.S * a.F);}
ll gcd (ll a,ll b){if(b==0)return a;else return gcd (b, a % b);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll min(ll a,ll b){if(a < b){return a;}return b;}
ll max(ll a,ll b){if(a > b){return a;}return b;}
double intlog(ll n ,ll base){return (double)log(n)/log(base);}
ll n , t , m , temp , temp2, root , p ,q , k , i , j , r , u , v , w;
struct comp { 
    bool operator()( pair<int, int> const& a, pair<int, int> const& b) { 
        return a.first < b.first || (a.first == b.first && a.second > b.second);
    } 
};

void transpose(vector<vi> & a){
    vector<vi> temp(n , vi(n));int i,j;
    fr(i , n){fr(j , n){temp[i][j] = a[j][i];}}
    a = temp;
}

ll solve(vi & a , ll i , ll val , ll p){
    if(i == a.size()){return val ^ p;}
    return min(solve(a , i + 1 , val , p | a[i]) , solve(a , i + 1 , val^p , a[i] ) );
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);
#endif
    cin>>n;
    vi a(n);
    fr(i , n)cin>>a[i];
    cout<<solve(a , 0 , 0 , 0)<<nl;;
#ifndef ONLINE_JUDGE
    cout << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s .\n";
#endif
}
#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
int main()
{
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    int n;
    cin >> n;
    int arr[n];
    int ans = 2000000000;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for(int mask = 0; mask < (1 << (n-1)); mask++)
    {
        int ore = 0;
        int xore = 0;
        for(int j = 0; j <= n; j++)
        {
            if(j < n) ore |= arr[j];

            if(j == n || (mask >> j&1))
            {
                xore ^= ore;
                ore = 0;
            }
        }
        ans = min(ans,xore);
    }
    cout << ans;
    return 0;
}