#include <cstdio>

#define rep(i,_l,_r) for(signed i=(_l),_end=(_r);i<=_end;++i)
#define fep(i,_l,_r) for(signed i=(_l),_end=(_r);i>=_end;--i)
#define erep(i,u) for(signed i=head[u],v=to[i];i;i=nxt[i],v=to[i])
#define efep(i,u) for(signed i=Head[u],v=to[i];i;i=nxt[i],v=to[i])
#define print(x,y) write(x),putchar(y)

template <class T> inline T read(const T sample) {
    T x=0; int f=1; char s;
    while((s=getchar())>'9'||s<'0') if(s=='-') f=-1;
    while(s>='0'&&s<='9') x=(x<<1)+(x<<3)+(s^48),s=getchar();
    return x*f;
}
template <class T> inline void write(const T x) {
    if(x<0) return (void) (putchar('-'),write(-x));
    if(x>9) write(x/10);
    putchar(x%10^48);
}
template <class T> inline T Max(const T x,const T y) {if(x>y) return x; return y;}
template <class T> inline T Min(const T x,const T y) {if(x<y) return x; return y;}
template <class T> inline T fab(const T x) {return x>0?x:-x;}
template <class T> inline T gcd(const T x,const T y) {return y?gcd(y,x%y):x;}
template <class T> inline T lcm(const T x,const T y) {return x/gcd(x,y)*y;}

int n,a[100];
long long ret=(1ll<<31);

int main() {
	n=read(9);
	rep(i,1,n) a[i]=read(9);
	rep(s,0,(1<<n-1)-1) {
		int tmp=0,ans=0;
		rep(i,1,n-1) 
			if((s>>i-1)&1) tmp|=a[i],ans^=tmp,tmp=0;
			else tmp|=a[i];
		tmp|=a[n],ans^=tmp;
		if(ret>ans) ret=ans;
	}
	print(ret,'\n');
	return 0;
}
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
#define ll long long int
#define pll pair<ll,ll>
#define vll vector<ll>
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define precise(x) fixed<<setprecision(x)
#define mod 1000000007
#define mod2 998244353
#define endl "\n"

ll ans = 1e18;
vll a(50);
ll n;
void recur(ll ind,ll cur,ll net,ll part)
{       
        if(ind >= n)
        {
                if(part == 0)
                        return;
                net ^= cur;
                ans = min(ans,net);
                return;
        }
        // take
        recur(ind+1,cur | a[ind],net,part);
        // break
        recur(ind+1,a[ind],net ^ cur,part+1);
}

void solve()
{
        cin >> n;
        for(ll i=0;i<n;i++)
                cin >> a[i];
        recur(0,0,0,0);
        cout << ans;
}int main()
{
    FAST;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
        solve();
    return 0;
}