#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int N = 1e6 + 5;
int n, a[N], num[(1 << 21) + 5][25];
inline void solve(int x, int step) {
  if (step == 22 || num[x][step] >= 2) return;
  num[x][step]++;
  solve(x, step + 1);
  if (x & (1 << step)) solve(x ^ (1 << step), step);
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int res, tp, ans = 0;
  for (int i = n; i >= 1; --i) {
    res = 0, tp = 0;
    for (int j = 21; j >= 0; --j) {
      if ((a[i] >> j) & 1)
        res |= (1 << j);
      else if (num[tp | (1 << j)][21] >= 2)
        res |= (1 << j), tp |= (1 << j);
    }
    solve(a[i], 0);
    if (i <= n - 2) ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
