#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long INF = 1e18;
const double eps = 1e-10;
const int maxn = 2e6 + 233;
int f[maxn], a[maxn], n;
void update(int x, int k) {
  if (k > 20) return;
  if (f[x] > 1) return;
  if (k == 20) f[x]++;
  update(x, k + 1);
  if (x >> k & 1) update(x ^ (1 << k), k + 1);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  int res = 0;
  for (int i = n; i >= 1; --i) {
    int ans = 0, t = 0;
    for (int j = 20; j >= 0; --j) {
      if (a[i] >> j & 1)
        ans |= 1 << j;
      else if (f[t | (1 << j)] > 1)
        ans |= 1 << j, t |= 1 << j;
    }
    update(a[i], 0);
    if (i <= n - 2) res = max(res, ans);
  }
  cout << res << '\n';
  return 0;
}
