#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1<<20;
int n,ans,Max[N],ok[N];
int main()
{
freopen("or_max.in","r",stdin);
freopen("or_max.out","w",stdout);
scanf("%d",&n);
for (int i=1,x;i<=n;i++)
scanf("%d",&x),ok[x]=1;
for (int i=0;i<20;i++)
for (int j=0;j<N;j++)
if (j>>i&1) ok[j^(1<<i)]|=ok[j];
for (int i=0;i<N;i++)
if (ok[i]) Max[i]=i;
for (int i=0;i<20;i++)
for (int j=0;j<N;j++)
if (j>>i&1) Max[j]=max(Max[j],Max[j^(1<<i)]);
for (int i=0;i<N;i++)
if (ok[i]) ans=max(ans,i|Max[(N-1)^i]);
printf("%d\n",ans);
return 0;
}