#include <bits/stdc++.h>
using namespace std;
ifstream fin("AAtest.in.txt");
const int c = (1 << 21) + 5;
int n, jad[1000005], a[c], vas;
void leia(int x) {
  int y = 0, m = 21;
  while (m--)
    if (!((x >> m) & 1) and a[(1 << m) + y] == 2) y += 1 << m;
  vas = max(vas, x | y);
}
void pane(int x, int k) {
  if (a[x] == 2) return;
  a[x]++;
  do {
    if (x >> k & 1) pane(x ^ 1 << k, k + 1);
  } while (++k < 21);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  cin >> n;
  for (int(i) = (0); ((i)) < ((n)); ((i))++) cin >> jad[i];
  for (int i = n - 1; i >= 0; i--) {
    if (i < n - 2) leia(jad[i]);
    pane(jad[i], 0);
  }
  cout << vas;
}
