#include <bits/stdc++.h>
using namespace std;
void getint(int &v) {
  char ch, fu = 0;
  for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') fu = 1, ch = getchar();
  for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
  if (fu) v = -v;
}
struct node {
  int x, y;
  node() { x = y = -1; }
  node(int X, int Y) { x = X, y = Y; }
  node operator+(const node &A) const {
    node B = A;
    if (x > B.x) {
      B.y = B.x;
      B.x = x;
    } else if (x > B.y)
      B.y = x;
    if (y > B.x) {
      B.y = B.x;
      B.x = y;
    } else if (y > B.y)
      B.y = y;
    return B;
  }
};
node a[2200000];
int b[1000010], n, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) getint(b[i]), a[b[i]] = a[b[i]] + node(i, -1);
  for (int j = 0; j <= 20; ++j)
    for (int i = 0; i <= (1 << 21) - 1; ++i)
      if ((i >> j) & 1) a[i ^ (1 << j)] = a[i ^ (1 << j)] + a[i];
  for (int i = 1; i <= n - 2; ++i) {
    int t = 0;
    for (int j = 20; j >= 0; --j) {
      if ((b[i] >> j) & 1) continue;
      if (a[t ^ (1 << j)].y > i) t ^= 1 << j;
    }
    ans = max(ans, b[i] ^ t);
  }
  cout << ans << endl;
  return 0;
}
