#include <bits/stdc++.h>
using namespace std;
int n;
int a[2100000];
pair<int, int> dp[2100000];
int id[2100000];
int id2[2100000];
pair<int, int> R(pair<int, int> A, pair<int, int> B) {
  pair<int, int> res = A;
  if (A.second > B.second) {
    res.first = max(res.first, B.second);
  } else {
    res = B;
    res.first = max(res.first, A.second);
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 1; i--) {
    if (id[a[i]] == 0) {
      id[a[i]] = i;
    } else if (id2[a[i]] == 0) {
      id2[a[i]] = i;
    }
  }
  int N = 21;
  int tar = (1 << N) - 1;
  for (int i = 0; i < (1 << N); ++i) dp[tar ^ i] = make_pair(id2[i], id[i]);
  for (int i = 0; i < N; ++i)
    for (int mask = 0; mask < (1 << N); ++mask) {
      if (mask & (1 << i)) dp[mask] = R(dp[mask], dp[mask ^ (1 << i)]);
    }
  int maxx = 0;
  for (int i = 1; i <= n - 2; i++) {
    int x = a[i];
    int rem = tar ^ x;
    pair<int, int> ans = make_pair(0, 0);
    int temp = 0;
    for (int j = N - 1; j >= 0; j--) {
      if (rem & (1 << j)) {
        temp |= (1 << j);
        ans = dp[tar ^ temp];
        if (ans.first < i) {
          temp -= (1 << j);
        }
      }
    }
    maxx = max(maxx, temp ^ a[i]);
  }
  cout << maxx << endl;
}
