#include <bits/stdc++.h>
using namespace std;
const int u = 1 << 21;
int a[u], f[u], g[u];
int main() {
  int n, ret = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    f[a[i]] = g[a[i]], g[a[i]] = i;
  }
  for (int i = 1; i < u; i <<= 1) {
    for (int j = u - 1 - i; j >= 0; j -= i << 1) {
      for (int k = 0; k < i; ++k) {
        if (g[j - k] > g[j - k + i])
          f[j - k] = max({f[j - k], g[j - k + i], f[j - k + i]});
        else if (g[j - k] == g[j - k + i])
          f[j - k] = max(f[j - k], f[j - k + i]);
        else
          f[j - k] = max(g[j - k], f[j - k + i]), g[j - k] = g[j - k + i];
      }
    }
  }
  for (int i = 1, v, w; i <= n - 2; i++) {
    for (v = u >> 1, w = 0; v; v >>= 1)
      if (!(a[i] & v) && f[w ^ v] > i) w ^= v;
    ret = max(ret, w ^ a[i]);
  }
  printf("%d\n", ret);
}
