#include <bits/stdc++.h>
using namespace std;
int f[5000010], a[1000010];
void dfs(int v, int k) {
  if (k < 0) return;
  if (f[v] >= 2) return;
  dfs(v, k - 1);
  if (v & (1 << k)) {
    dfs(v ^ (1 << k), k - 1);
    f[v ^ (1 << k)]++;
  }
}
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  dfs(a[n], 21);
  f[a[n]]++;
  dfs(a[n - 1], 21);
  f[a[n - 1]]++;
  for (int i = n - 2; i; --i) {
    int res = 0;
    for (int j = 1 << 21; j; j >>= 1)
      if ((a[i] & j) == 0) {
        if (f[res | j] >= 2) res |= j;
      }
    ans = max(ans, a[i] | res);
    dfs(a[i], 21);
    f[a[i]]++;
  }
  cout << ans;
}
