#include <bits/stdc++.h>
using namespace std;
const int prime = 999983;
const int INF = 0x7FFFFFFF;
const long long INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const long long mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long s = 1;
  while (b > 0) {
    if (b & 1) s = s * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return s;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
const int maxn = 1e6 + 10;
int a[maxn];
int dp[1 << 21];
void update(int num, int k, bool flag) {
  if (k > 20) return;
  if (dp[num] > 1) return;
  update(num, k + 1, 1);
  if (!flag) dp[num]++;
  if (num >> k & 1) update(num ^ (1 << k), k, 0);
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int ans = 0;
  for (int i = n; i >= 1; --i) {
    int res = 0;
    int t = 0;
    for (int j = 20; j >= 0; --j) {
      if (a[i] >> j & 1)
        res |= 1 << j;
      else if (dp[t | (1 << j)] > 1)
        res |= 1 << j, t |= 1 << j;
    }
    update(a[i], 0, 0);
    if (i <= n - 2) ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
