#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   (*(x.begin()))
#define le(x)                   (*(x.rbegin()))
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x,id)               (*(x.find_by_order(id)))
#define ook(y)                  order_of_key(y)
#define all(x)                  (x).begin(),(x).end()
#define si(a)                   scanf("%d",&a)
#define sii(a,b)                scanf("%d %d",&a,&b)
#define siii(a,b,c)             scanf("%d %d %d",&a,&b,&c)
#define sl(a)                   scanf("%lld",&a)
#define sll(a,b)                scanf("%lld %lld",&a,&b)
#define slll(a,b,c)             scanf("%lld %lld %lld",&a,&b,&c)
#define rep(i,a,b)              for(ll i = a; i<=b;  i++)
#define un(x)                   x.erase(unique(all(x)), x.end())
#define TT                      long long TC;  scanf("%lld",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
#define assign(v,n,x)           v.clear(); for(int I = 0; I<n; I++)    v.pb(x);
#define SZ(x)                   (int)x.size()
#define ff                      first
#define ss                      second
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

#define mx 23

ll ar[mx];
ll MX = 1e12,n;

ll ans = MX;


void fn(ll pos,ll w = 0,ll Or = 0){
    if(pos==n){
        w^=Or;
        ans = min(ans,w);
        return;
    }
    ll p = Or|ar[pos];
    fn(pos+1,w^p,0);
    fn(pos+1,w,p);
}


main(){
//read;

sl(n);

for(ll i = 0; i<n; i++){
    sl(ar[i]);
}

fn(0);

cout<<ans;





return 0;
}



// Problem: C - ORXOR
// Contest: AtCoder - AtCoder Beginner Contest 197（Sponsored by Panasonic）
// URL: https://atcoder.jp/contests/abc197/tasks/abc197_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pi  3.141592653589793238462643383279
#define int long long
#define lld long double
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define VI vector <int>
#define VVI vector <VI>
#define pii pair<int, int>
#define ppi pair<pii, int>
#define mii map<int, int>
#define mci map<char, int>
#define miv map<int, VI>
#define mis map<int, set<int>>
#define high_functioning_sociopath  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const unsigned int M = 998244353;
/*_____________________________THE GAME IS ON_____________________________*/
void solve()
{
      int n;
      cin >> n;
      int res = 1e17;
      vector<int>arr(n);
      for(int i=0;i<n;i++) cin >> arr[i];
      for(int mask=0;mask<(1<<(n-1));mask++)
      {
      	   int x = 0;
      	   int o = 0;
      	   for(int i=0;i<n;i++)
      	   {
      	   	   if(!(mask&(1<<i)))
      	   	   {
      	   	   	   o|=arr[i];
      	   	   }
      	   	   else
      	   	   {
      	   	   	   o|=arr[i];
      	   	   	   x^=o;
      	   	   	   o=0;
      	   	   }
      	   }
      	   x^=o;
      	   res = min(x,res);
      }
      cout << res;
}
int32_t main()
{
   high_functioning_sociopath
   //pre();
   int t=1;
   //cin>>t;
   while(t--)
   {
      solve();
   }
}