#include <bits/stdc++.h>
using namespace std;
const int maxn = 1123456;
int n, ans, clk;
int a[maxn], cnt[2 * maxn], vis[2 * maxn];
void dfs(int u) {
  if (vis[u] == clk) return;
  if (cnt[u] >= 2) return;
  cnt[u]++;
  vis[u] = clk;
  for (int(i) = (21); (i) >= (0); (i)--)
    if (u & (1 << i)) dfs(u ^ (1 << i));
}
int main() {
  scanf("%d", &n);
  for (int(i) = (1); (i) <= (n); (i)++) scanf("%d", a + i);
  for (int(i) = (n); (i) >= (1); (i)--) {
    if (i <= n - 2) {
      int mask = 0, cur = 0;
      for (int(j) = (21); (j) >= (0); (j)--) {
        if (a[i] & (1 << j)) {
          mask |= 1 << j;
          continue;
        }
        if (cnt[cur | (1 << j)] >= 2) {
          mask |= 1 << j;
          cur |= 1 << j;
        }
      }
      ans = max(ans, mask);
    }
    ++clk;
    dfs(a[i]);
  }
  printf("%d", ans);
}
