#include <bits/stdc++.h>
using namespace std;
const int maxn = 8100000;
int n, a[maxn], f[maxn], ans, lst[maxn];
void insert(int x, int y) {
  if (f[x] >= 2 || lst[x] == y) return;
  f[x]++;
  lst[x] = y;
  for (int i = 0; i <= 22; i++)
    if (x & (1 << i)) insert(x ^ (1 << i), y);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  insert(a[n], n);
  insert(a[n - 1], n - 1);
  for (int i = n - 2; i >= 1; i--) {
    int maxx = 0;
    for (int j = 22; j >= 0; j--)
      if (!(a[i] & (1 << j))) {
        maxx |= (1 << j);
        if (f[maxx] < 2) maxx ^= (1 << j);
      }
    ans = max(ans, a[i] | maxx);
    insert(a[i], i);
  }
  printf("%d\n", ans);
  return 0;
}
