#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 1<<17;
struct xorshift32 {
unsigned x,y,z,w;
xorshift32(): x(123456789), y(2378257), z(7777777), w(85715718) {}
unsigned next() {
unsigned t=x^(x<<11);
x=y;y=z;z=w;
return w=w^(w>>19)^t^(t>>8);
}
unsigned next(unsigned n) {
return next()%n;
}
int next(int a, int b) {
return a+next(b-a+1);
}
};
int tests,current_case;
int n,a[N];
long long ans;
xorshift32 rng;
void message(int current_case) {
//cerr<<"Case "<<current_case<<" solved!"<<endl;
fprintf(stderr, "Case %d solved!\n", current_case);
}
int main() {
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int i,j;
tests=1;
//scanf("%d", &tests);
//cin>>tests;
for(current_case=1;current_case<=tests;current_case++) {
scanf("%d", &n);
for(i=1;i<=n;i++) {
scanf("%d", &a[i]);
}
sort(a+1,a+1+n);
while(clock()<=1.7*CLOCKS_PER_SEC) {
if(n>1000) {
i=1+rng.next(n-1000,n);
j=1+rng.next(n-1000,n-1);
if(j>=i) ++j;
ans=max(ans,(a[i]|a[j])*1ll*(a[i]&a[j]));
}
else {
i=1+rng.next(1,n);
j=1+rng.next(1,n-1);
if(j>=i) {
++j;
}
ans=max(ans,(a[i]|a[j])*1ll*(a[i]&a[j]));
}
}
printf("%lld\n", ans);
MESSAGE:
message(current_case);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZW5kbCAnXG4nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE4gPSAxPDwxNzsKCnN0cnVjdCB4b3JzaGlmdDMyIHsKICAgIHVuc2lnbmVkIHgseSx6LHc7CiAgICB4b3JzaGlmdDMyKCk6IHgoMTIzNDU2Nzg5KSwgeSgyMzc4MjU3KSwgeig3Nzc3Nzc3KSwgdyg4NTcxNTcxOCkge30KICAgIHVuc2lnbmVkIG5leHQoKSB7CiAgICAgICAgdW5zaWduZWQgdD14Xih4PDwxMSk7C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wMCxuKTsKICAgICAgICAgICAgICAgIGo9MStybmcubmV4dChuLTEwMDAsbi0xKTsKICAgICAgICAgICAgICAgIGlmKGo+PWkpICsrajsKICAgICAgICAgICAgICAgIGFucz1tYXgoYW5zLChhW2ldfGFbal0pKjFsbCooYVtpXSZhW2pdKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBpPTErcm5nLm5leHQoMSxuKTsKICAgICAgICAgICAgICAgIGo9MStybmcubmV4dCgxLG4tMSk7CiAgICAgICAgICAgICAgICBpZihqPj1pKSB7CiAgICAgICAgICAgICAgICAgICAgKytqOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgYW5zPW1heChhbnMsKGFbaV18YVtqXSkqMWxsKihhW2ldJmFbal0pKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwcmludGYoIiVsbGRcbiIsIGFucyk7CiAgICAgICAgCiAgICAgICAgTUVTU0FHRToKICAgICAgICBtZXNzYWdlKGN1cnJlbnRfY2FzZSk7CiAgICB9CgogICAgcmV0dXJuIDA7Cn0=