#include <bits/stdc++.h>

using namespace std;
#define ll long long

const ll OO = 0x3f3f3f3f;
const ll mod =   1e9 + 7;
const double pi = 3.14159265359;

//freopen("window.in", "r", stdin);
//freopen("output.out", "w", stdout);
void skrrrt() {
    ios_base::sync_with_stdio(0), cin.tie(0);
}
//###############################Spaggetti############################
int n;
int a[22];
ll ans=1e15;
void solve(int ind,ll num){
    if(ind==n){
        ans=min(ans,num);
        return ;
    }

    int orr=0;
    for(int i=ind;i<n;i++){
        orr|=a[i];
        solve(i+1,orr^num);
    }

}
int main(){
    skrrrt();
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    solve(0,0);
    cout<<ans;
}

// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int> 
#define Vb vector<bool>
#define Pi pair<int, int>
#define Si set<int> 
#define Ui unordered_map<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define _USE_MATH_DEFINES
#define int long long
using namespace std;
using namespace std::chrono;



int mod_power(int x, int y, int mod){
  int ans = 1;
  x %= mod;
  while(y){
    if (y & 1)
      ans *= x, ans %= mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return ans;
}

int mod_inverse(int n, int mod){
  return mod_power(n, mod - 2, mod);
}

 
// Returns factorial of n 
int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
}
  
int ncr(int n, int r) 
{
  if (r > n)
    return 0;
  if (r == 0 or r == n)
    return 1;
  int fact = 1;
  for (int i = 1; i <= r; i++)
    fact *= i;
  int ans = 1;
  for (int i = n; i > n - r; i--)
    ans *= i;
  ans /= fact;
  return ans; 
} 
    

int mod_ncr(int n, int r, int mod){
  if (r > n)
    return 0;
  if (r == 0 or r == n)
    return 1;
  int fact = 1;
  for (int i = 1; i <= r; i++)
    fact *= i, fact %= mod;
  int ans = 1;
  for (int i = n; i > n - r; i--)
    ans *= i, ans %= mod;
  ans *= mod_inverse(fact, mod), ans %= mod;
  return ans;
}

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}

Vi divisors(int n){
  Vi front;
  Vi back;
  
  for (int i = 1; i <= sqrt(n); i++){
    if (n % i == 0)
      if (i == n / i)
	front.pb(i);
      else
	front.pb(i), back.pb(n / i);
  }
  for (int i = back.size() - 1; i >= 0 ; i--)
    front.pb(back[i]);
  return front;
}


int DCNT(int a){
  int ans = 0;
  while(a)
    ans++, a/=10;

  return ans;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);


  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int min_ = pow(2, 30) + 10;
  for (int i = 0; i < pow(2, n - 1); i++){
    int ii = i;
    Vi v;
    while(ii)
      v.pb(ii % 2), ii /= 2;
    int x = n - 1 - v.size();
    for (int j = 0; j < x; j++)
      v.pb(0);
    int ans = 0;
    int p = a[0];
    for (int j = 0; j < n - 1; j++){
      if (v[j])
	ans ^= p, p = 0;
      p |= a[j + 1];
    }
    
    ans ^= p;
    min_ = min(min_, ans);
  }

  cout << min_ << endl;
}
