#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long readll() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = (1 << 21) + 100;
int n, a[MAXN], b;
pair<int, int> dp[MAXN];
void add(int s, int v) {
  if (!dp[s].first)
    dp[s].first = v;
  else if (!dp[s].second) {
    if (v == dp[s].first) return;
    dp[s].second = v;
    if (dp[s].first < dp[s].second) swap(dp[s].first, dp[s].second);
  } else {
    if (v > dp[s].first) {
      dp[s].second = dp[s].first;
      dp[s].first = v;
    } else if (v != dp[s].first && v > dp[s].second) {
      dp[s].second = v;
    }
  }
}
void merge(int s1, int s2) {
  if (dp[s2].first) add(s1, dp[s2].first);
  if (dp[s2].second) add(s1, dp[s2].second);
}
inline int highbit(int x) { return (int)log2(x) + 1; }
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    add(a[i], i);
    b = max(b, highbit(a[i]));
  }
  for (int i = 0; i < b; ++i) {
    for (int s = 0; s < (1 << b); ++s) {
      if (s & (1 << i)) {
        merge(s ^ (1 << i), s);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n - 2; ++i) {
    int goal = (1 << b) - 1 - a[i], opt = 0;
    for (int j = b - 1; j >= 0; --j) {
      if (goal & (1 << j)) {
        if (dp[opt ^ (1 << j)].second > i) {
          opt ^= (1 << j);
        }
      }
    }
    ans = max(ans, a[i] ^ opt);
  }
  cout << ans << endl;
  return 0;
}
