#include <bits/stdc++.h>
using namespace std;
int p[25], temp[(1 << 22) - 1], a[1000005];
void f(int x, int k) {
  if (temp[x] >= 2) return;
  temp[x]++;
  while (k <= 21) {
    if (x & p[k]) f(x ^ p[k], k + 1);
    k++;
  }
}
void solve() {
  int n, res = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  temp[0] = 1;
  f(a[n], 0), f(a[n - 1], 0);
  for (int i = n - 2; i >= 1; i--) {
    int x = 0;
    for (int j = 21; j >= 0; j--)
      if (!(a[i] & p[j])) {
        x ^= p[j];
        if (temp[x] < 2) x ^= p[j];
      }
    res = max(res, (x ^ a[i]));
    f(a[i], 0);
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t z = clock();
  p[0] = 1;
  for (int i = 1; i < 25; i++) p[i] = 2 * p[i - 1];
  int qc = 1;
  for (int i = 1; i <= qc; i++) {
    solve();
  }
  fprintf(stderr, "Total Time:%.4Lf\n",
          (long double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
}
