#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
int nowarn;
int n, a[1<<20] = {0};
void or_fwt( int *a ) {
for( int m = 2; m <= (1<<20); m <<= 1 )
for( int i = 0; i < (1<<20); i += m )
for( int j = 0; j < (m>>1); ++j )
a[i+j+(m>>1)] += a[i+j];
}
void or_ifwt( int *a ) {
for( int m = 2; m <= (1<<20); m <<= 1 )
for( int i = 0; i < (1<<20); i += m )
for( int j = 0; j < (m>>1); ++j )
a[i+j+(m>>1)] -= a[i+j];
}
int main() {
freopen( "or_max.in", "r", stdin );
freopen( "or_max.out", "w", stdout );
nowarn = scanf( "%d", &n );
for( int i = 0; i < n; ++i ) {
int x;
nowarn = scanf( "%d", &x );
a[x] = 1;
}
or_fwt(a);
for( int i = 0; i < (1<<20); ++i ) a[i] *= a[i];
or_ifwt(a);
for( int i = (1<<20)-1; i >= 0; --i )
if( a[i] ) {
printf( "%d\n", i );
break;
}
return 0;
}