#include <bits/stdc++.h>
using namespace std;
const long long P = 1e9 + 7;
const int N = 2e6 + 5;
const long long INF = 1e16;
const double pi = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, cnt[N], ans, a[N];
void insert(int x, int y) {
  if (cnt[x | y] == 2) return;
  if (x == 0) {
    cnt[y]++;
    return;
  }
  insert(x & x - 1, y | x & -x);
  insert(x & x - 1, y);
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", a + i);
  for (int i = (n); i >= (1); --i) {
    if (i + 2 <= n) {
      int now = 0;
      for (int j = (20); j >= (0); --j)
        if (!(a[i] >> j & 1) && cnt[now | 1 << j] == 2) now |= 1 << j;
      ans = max(ans, now | a[i]);
    }
    insert(a[i], 0);
  }
  printf("%d\n", ans);
  return 0;
}
