#include<bits/stdc++.h>
const int maxn=1e6;
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();
}
}
inline const void write(int a)
{
if(a>9)write(a/10);
putchar(a%10+'0');
}
inline const int max(int a,int b)
{
if(a>b)return a;
else return b;
}
inline const int min(int a,int b)
{
if(a<b)return a;
else return b;
}
int n,d=0;
int point[maxn],next[maxn],to[maxn],len[maxn];
int exboy[maxn],exgirl[maxn],boy[maxn],girl[maxn],three[maxn];
bool visboy[maxn],visgirl[maxn];
const bool found(int p)
{
visboy[p]=true;
int side=point[p];
while(side)
{
if(!visgirl[to[side]])
{
if(exboy[p]+exgirl[to[side]]==len[side])
{
visgirl[to[side]]=true;
if(!girl[to[side]]||found(girl[to[side]]))
{
girl[to[side]]=p;
boy[p]=to[side];
return true;
}
}
else
if(exboy[p]+exgirl[to[side]]-len[side]>0)
three[to[side]]=min(three[to[side]],exboy[p]+exgirl[to[side]]-len[side]);
}
side=next[side];
}
return false;
}
void solve()
{
for(int i=1;i<=n;i++)
{
memset(three,0x7f,sizeof(three));
while(true)
{
memset(visgirl,false,sizeof(visgirl));
memset(visboy,false,sizeof(visboy));
if(found(i))break;
int minus=three[0];
for(int j=1;j<=32;j++)if(!visgirl[j])minus=min(three[j],minus);
if(minus==three[0])break;
for(int j=1;j<=n;j++)if(visboy[j])exboy[j]-=minus;
for(int j=1;j<=32;j++)
if(visgirl[j])exgirl[j]+=minus;
}
}
}
inline const void add(int a,int b,int c)
{
next[++d]=point[a];
to[d]=b;
point[a]=d;
len[d]=c;
exboy[a]=max(exboy[a],len[d]);
}
int main()
{
memset(exboy,0,sizeof(exboy));
memset(exgirl,0,sizeof(exgirl));
memset(girl,0,sizeof(girl));
memset(boy,0,sizeof(boy));
read(n);
int k;
for(int i=1;i<=n;i++)
{
read(k);
for(int j=1;j<=32;j++)
if((1<<j-1)&k)add(i,j,1<<j-1);
}
solve();
int ans=0;
for(int i=1;i<=n;i++)
{
if(boy[i])ans+=1<<boy[i]-1;
else ans^=1;
}
write(ans);
return 0;
}