#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int a[22];
    int st[22];
    int orr[22];
    int xorr;
    int cnt;
    int temp;
    long long min;
    int aa = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < (1 << (n-1)); i++){
        cnt = 0;
        for (int j = 0; j < (n-1); j++){
            if (i >> j & 1){
                st[j] = 1;
                cnt++;
            } else{
                st[j] = 0;
            }
        }
        for (int j = 0; j < n; j++){
            orr[j] = 0;
        }
        temp = 0;
        aa  = 1;
        for (int j = 0; j < n; j++){
            if (aa != 1){
                orr[temp] = a[j] | orr[temp];
            } else{
                orr[temp] = a[j];
                aa = 0;
            }
            if (st[j] == 1) {
                temp++;
                aa = 1;
            }
        }
        xorr = orr[0];
        for (int j = 1; j <= cnt; j++){
           xorr = xorr ^ orr[j];
        }
        if (i == 0){
            min = xorr;
        } else{
            if (min > xorr) {
                min = xorr;
            }
        }
    }
    printf("%lld", min);
}
/**
*    author:  Takeda Takumi
*    created: 30.03.2021 16:14:34
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for (int i = s; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
   
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   int ans = 1<<30;
   rep(s, 0, 1<<(n-1))
   {
       int now = 0;
       int o = 0;
       rep(i,0,n)
       {
           o |= a[i];
           if(s>>i&1){
               now ^= o;
               o = 0;
           }
       }
       now ^= o;
       ans = min(ans, now);
   }
   cout << ans << endl;
   return 0;
}