#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 3e6 + 10;
int n, a[N], vis[N], pre[N];
pair<int, int> dp[N];
void add(int s, int p) {
  if (!dp[s].first) return dp[s].first = p, void();
  if (!dp[s].second) return dp[s].second = p, void();
  if (dp[s].first < p) dp[s].first = p;
  if (dp[s].first > dp[s].second) swap(dp[s].first, dp[s].second);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), add(a[i], i);
  int mx = (1 << 21) - 1;
  for (int i = 0; i <= 21; ++i)
    for (int j = 0; j <= mx; ++j)
      if (j >> i & 1) {
        if (dp[j].first) add(j ^ 1 << i, dp[j].first);
        if (dp[j].second) add(j ^ 1 << i, dp[j].second);
      }
  for (int i = 1; i <= n - 2; ++i) vis[i] = 1;
  int ans = 0;
  for (int d = 21; d >= 0; --d) {
    for (int i = 1; i <= n; ++i)
      if (vis[i]) {
        if (a[i] >> d & 1 ^ 1) {
          pre[i] ^= 1 << d;
          if (!dp[pre[i]].second || dp[pre[i]].first <= i) vis[i] = -1;
        }
      }
    for (int i = 1; i <= n; ++i)
      if (vis[i] == 1) ans |= 1 << d;
    for (int i = 1; i <= n; ++i)
      if (vis[i] == -1) {
        if (ans >> d & 1)
          vis[i] = 0;
        else
          vis[i] = 1, pre[i] ^= 1 << d;
      }
  }
  printf("%d\n", ans);
}
