#include <bits/stdc++.h>
using namespace std;
int Left[1 << 21], Right[1 << 21][2], n;
void Put(int a, int b) {
  if (Right[a][0] == b || Right[a][1] == b) return;
  if (Right[a][1] >= b) return;
  if (Right[a][0] < b) {
    Right[a][1] = Right[a][0];
    Right[a][0] = b;
  } else
    Right[a][1] = b;
}
bool Pos(int a) {
  int i;
  for (i = 0; i < (1 << 21); i++) {
    int t = Right[i][1];
    int tp = (a & (~i));
    if (Left[tp] < t) {
      return true;
    }
  }
  return false;
}
int main() {
  int i, j, k, a;
  scanf("%d", &n);
  for (i = 0; i < (1 << 21); i++) Left[i] = 1e9;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    if (Left[a] > 1e8) Left[a] = i;
    Right[a][1] = Right[a][0];
    Right[a][0] = i;
  }
  for (i = (1 << 21) - 1; i >= 0; i--) {
    for (j = 0; j < 21; j++) {
      if ((i >> j) & 1) continue;
      Left[i] = min(Left[i], Left[i ^ (1 << j)]);
      Put(i, Right[i ^ (1 << j)][0]);
      Put(i, Right[i ^ (1 << j)][1]);
    }
  }
  int s = 0;
  for (i = 20; i >= 0; i--) {
    s += (1 << i);
    if (!Pos(s)) s -= (1 << i);
  }
  printf("%d\n", s);
}
