#include <bits/stdc++.h>
using namespace std;

int a[25];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d", &a[i]);
    }
    int ans = 2e9;
    for(int i=0;i<(1<<n);i++){
        int sum = 0, res = 0;
        for(int j=0;j<n;j++){
            sum |= a[j];
            if(j == n-1 || ((i>>j)&1)){
                res ^= sum;
                sum = 0;
            }
        }
        ans = min(ans, res);
    }
    printf("%d\n", ans);
}
#include <bits/stdc++.h>
using namespace std;
#define BUFF ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define DEBUG(var) cout << #var << "=" << var << '\n'
#define WARN puts("warning!")
#define REP(i, a, n) for (int i = a; i <= n; ++i)
#define PER(i, n, a) for (int i = n; i >= a; --i)
#define LL int64_t
template<typename T>void Read(T &x){x=0;char ch=getchar();LL f=1;while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}x*=f;}
template<typename T>int64_t __lcm(T a, T b){return a/__gcd(a,b)*b;}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int64_t Rand(LL a,LL b) {return a + rng() % (b-a+1);}
inline int64_t QuickPow(LL base,LL n,LL Mod = 0){LL ret(1);while(n){if(n&1){ret*=base;if(Mod)ret%=Mod;}base*=base;if(Mod)base%=Mod;n>>=1;}return Mod?ret%Mod:ret;}
inline int64_t Inv(LL x,LL p){return QuickPow(x,p-2,p);}
inline void gettime(){time_t rawtime;struct tm *ptminfo;time(&rawtime);ptminfo = localtime(&rawtime);printf("Current time: %02d-%02d-%02d %02d:%02d:%02d\n",ptminfo->tm_year + 1900, ptminfo->tm_mon + 1, ptminfo->tm_mday,ptminfo->tm_hour, ptminfo->tm_min, ptminfo->tm_sec);}
const double pi = acos(-1.0);
const LL kInf(LONG_LONG_MAX);
const LL kMod(998244353);
const LL kMax(210);
LL group(1);

inline void Solve()
{
    /*write your code down here*/
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &it:v)Read(it);
    int res = INT_MAX;
    for(int i = 0;i < (1<<(n-1));i++)
    {
        int XOR = 0,OR = 0;
        for(int j = 0;j <= n;j++)
        {
            if(j < n)OR |= v[j];
            if(j == n ||  ((i>>j) &1))XOR ^= OR,OR = 0;
        }
        res = min(res,XOR);
    }
    cout<<res<<'\n';
}
int main()
{
    //gettime();
    //WARN;
    //Read(group);
    while (group--)
    {
        Solve();
    }
    return 0;
}


