#include<cstdio>
#include<iostream>
using namespace std;
int n;
const int N=1<<21;
int pos[N],bit[N];
int a[N],b[N];
long long c[N];
void fwt(int a[])
{
for (int i=2;i<=N;++i)
if (pos[i]>i) swap(a[pos[i]],a[i]);
int p,q;
for (int i=2;i<=N;i<<=1)
for (int j=0;j<N;j+=i)
for (int k=0;k<i/2;++k)
a[j+k]+=a[j+k+i/2];
}
void ufwt(long long a[])
{
for (int i=2;i<=N;++i)
if (pos[i]>i) swap(a[pos[i]],a[i]);
int p,q;
for (int i=2;i<=N;i<<=1)
for (int j=0;j<N;j+=i)
for (int k=0;k<i/2;++k)
a[j+k]-=a[j+k+i/2];
}
main()
{
freopen("and_min.in","r",stdin);
freopen("and_min.out","w",stdout);
scanf("%d",&n);
for (int t=0,i=1;i<N;i<<=1,++t) bit[i]=t;
for (int i=1;i<N;++i) pos[i]=pos[i^(i&-i)]|(1<<21-bit[i&-i]-1);
for (int x,i=1;i<=n;++i)
scanf("%d",&x),
++a[x];
for (int i=1;i<N;++i) b[i]=a[i];
fwt(a);
fwt(b);
for (int i=0;i<N;++i) c[i]=1LL*a[i]*b[i];
ufwt(c);
c[0]-=n;
for (int i=0;i<N;++i)
if (c[i]>0) return printf("%d\n",i),0;
}