#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;
}