#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define endl            "\n"
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
void __print(int32_t x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
void fastIO()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void solve()
{
    int n;
    cin>>n;
    int ar[n];

    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }

    vector<pii> ans;

    ans.pb({0,ar[0]});


    for(int j=1;j<n;j++)
    {
        int sz = ans.size();

        for(int i=0;i<sz;i++)
        {
            ans.pb({ans[i].ff^ans[i].ss,ar[j]});
            //.//debug(ans[i]);
            ans[i].ss=ans[i].ss|ar[j];
            ///debug(ans[i]);
        }
        //debug(ans);
    }

    int ret = inf;

    for(pii i: ans)
    {
        //debug(i);
        ret = min(ret, i.ff^i.ss);
    }

    cout<<ret;
}
 
int32_t main()
{
    fastIO();
    //w(t)
    {
        solve();
        cout<<endl;
    }
    return 0;
}
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define mod              1000000000000007
#define ff              first
#define int             long long
#define pb              push_back

void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int arr[21];
int orr[21][21];
void make_or(int n)
{
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      orr[i][j] = 0;
  for (int i = 0; i < n; i++)
  {
    int ans = 0;
    for (int j = i; j < n; j++)
    {
      ans = ans | arr[j];
      orr[i][j] = ans;
    }
  }

  return;
}

int32_t main()
{
  c_p_c();
  int n;
  cin >> n;

  for (int i = 0; i < n; i++)
    cin >> arr[i];
  make_or(n);


  int finland = mod;
  int val = pow(2, n) - 1;
  for (int rrr = 1; rrr <= val; rrr++)
  {
    int l = 0;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
      if (rrr & (1 << i))
      {
        ans ^= orr[l][i];
        l = i + 1;
      }
    }
    if (l < n)
      ans ^= orr[l][n - 1];

    finland = min(finland, ans);
  }
  cout << finland << endl;
  return 0;
}

