#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e6+10;
const double eps = 0.01;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
inline ll pt(ll ans,ll f){
    printf("%lld",ans);
    if(f==1) putchar(' ');
    else putchar('\n');
}
ll n,k,m,tot;
ll a[N],c[N],vis[N],mi=1e10;
void dfs(int x,ll now){
    if(x==n+1) mi=min(mi,now);
    ll res=0;
    for(int i=x;i<=n;i++){
        res|=a[i];
        dfs(i+1,res^now);
    }
}
int main()
{
//    freopen("../in.in","r",stdin);
    ll _;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dfs(1,0);
    cout<<mi<<endl;
    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)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	mk(a,n,ll)
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=inf;
	for(ll i=0;i<(1<<(n-1));i++){
		vr c;
		ll sum=a[0];
		for(ll j=1;j<n;j++){
			if((i&(1<<(j-1)))){
				c.pb(sum);
				sum=a[j];
			}else{
				sum|=a[j];
			}
		}
		c.pb(sum);
		// for(ll j=0;j<c.size();j++){
			// cout<<c[j]<<" ";
		// }
		// cout<<"\n";
		ll x=0;
		for(ll j=0;j<c.size();j++){
			x^=c[j];
		}
		ans=min(ans,x);
	}
	cout<<ans<<"\n";
	delete[] a;
	return 0;
}
	
	
	
	
	

