#include<bits/stdc++.h>
using namespace std;
int n,a[1001],v[32][1001],h[1001],ans2[32],b[1001][31];//h±íʾÒѾȡ³öµÄÊýµÄ±ê¼Ç
long long ans=0;
struct node
{
int a,data;
};
inline const void read(int &a)
{
a=0;
char c=getchar();
while(c<'0'||c>'9') c=getchar();
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
}
bool com1(node aa,node bb)
{
return aa.data<bb.data;
}
void find(node *x,int len)
{
//if(p==1)
//for(int i=1;i<=len;i++)
//cout<<"temp["<<i<<"].a="<<x[i].a<<" temp["<<i<<"].data="<<x[i].data<<endl;
node temp[1001];
int jk=0;
sort(x+1,x+1+len,com1);
if(x[1].data==0)
{
h[x[1].a]=1;
return;
}
temp[++jk].a=x[1].a;
for(int i=1;i<=b[x[1].a][0];i++)
{
//cout<<b[x[1].a][i]<<' '<<x[1].data<<endl;
if(b[x[1].a][i]<x[1].data)
{
//cout<<"**\n";
temp[jk].data=b[x[1].a][i];
break;
}
}
for(int i=2;i<=len;i++)
{
if(x[i].data==x[i-1].data)
{
temp[++jk].a=x[i].a;
for(int o=1;o<=b[x[i].a][0];o++)
{
if(b[x[i].a][o]<x[i].data)
{
temp[jk].data=b[x[i].a][o];
break;
}
}
}
else break;
}
if(jk==1)
{
//cout<<"*********\n";
//cout<<"temp["<<jk<<"].a="<<temp[jk].a<<" temp["<<jk<<"].data="<<temp[jk].data<<endl;
//cout<<"**********\n";
h[temp[jk].a]=1;
return;
}
else
{
//cout<<"**&&&&**\n";
//for(int jj=1;jj<=jk;jj++)
//cout<<"temp["<<jj<<"].a="<<temp[jj].a<<" temp["<<jj<<"].data="<<temp[jj].data<<endl;
//cout<<"**&&&&**\n";
find(temp,jk);
}
}
bool com(int a,int b)
{
return a>b;
}
int main()
{
//freopen("ji.in.txt","r",stdin);
int i,k,s;
memset(v,0,sizeof(v));
memset(h,0,sizeof(h));
memset(ans2,0,sizeof(ans2));
read(n);
for(i=1;i<=n;i++) read(a[i]);
for(i=1;i<=n;i++)
{
for(k=31;k>=0;k--)
{
if(((unsigned int)1<<k)<=a[i]&&(a[i]&((unsigned int)1<<k)))
{
b[i][++b[i][0]]=k;
v[k][++v[k][0]]=i;
}
}
}
//for(int o=1;o<=n;o++)
//for(int x=1;x<=b[o][0];x++)
//cout<<"b["<<o<<"]["<<x<<"]="<<b[o][x]<<endl;
//for(int i=0;i<=31;i++)
//cout<<v[i][0]<<' ';
//cout<<endl;
for(i=31;i>=0;i--)
{//cout<<"**"<<i<<endl;
if(v[i][0])
{
//cout<<"v["<<i<<"][0]="<<v[i][0]<<endl;
if(v[i][0]==1&&!h[v[i][1]])
{
ans2[i]=1;
h[v[i][1]]=1;
}
else
{//cout<<"**"<<i<<endl;
node temp[1001];
int jk=0;
//for(int j=1;j<=v[i][0];j++)
//cout<<"v["<<i<<"]["<<j<<"]="<<v[i][j]<<' ';
//cout<<endl;
for(int j=1;j<=v[i][0];j++)
{
if(!h[v[i][j]])
{
// cout<<")()(\n";
temp[++jk].a=v[i][j];
int mm=0;
for(int o=1;o<=b[v[i][j]][0];o++)
{
//cout<<"j="<<v[i][j]<<" vvv="<<b[v[i][j]][o]<<endl;
if(!ans2[b[v[i][j]][o]]&&b[v[i][j]][o]<=i)
{
mm++;
if(mm==2)
{
temp[jk].data=b[v[i][j]][o];
break;
}
}
}
}
}
//cout<<endl<<"i="<<i<<" v["<<i<<"][0]="<<v[i][0]<<" jk="<<jk<<endl;
//for(int lk=1;lk<=jk;lk++)
//cout<<"temp["<<lk<<"].a="<<temp[lk].a<<" temp["<<lk<<"].data="<<temp[lk].data<<endl;
//for(int ww=1;ww<=n;ww++)
//cout<<"h["<<ww<<"]="<<h[ww]<<' ';
//cout<<endl;
if(jk)
{
ans2[i]=1;
find(temp,jk);
}
}
}
}
for(i=1;i<=n;i++)
{
if(!h[i])
ans2[0]=abs(ans2[0]-1);
}
for(i=0;i<=31;i++)
if(ans2[i])
ans+=((unsigned int)1<<i);
cout<<ans<<endl;
return 0;
}