#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000000 + 100;
int n, a[maxn], f[maxn];
void add(int x, int b = 0) {
  if (f[x] >= 2) return;
  f[x]++;
  for (int i = b; i <= 20; i++) {
    if ((x >> i) & 1) {
      add(x ^ (1 << i), i);
    }
  }
}
void work() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int ret = 0;
  for (int i = n - 1; i >= 0; i--) {
    int s = 0;
    for (int j = 20; j >= 0; j--) {
      if ((a[i] >> j) & 1) continue;
      int t = s | (1 << j);
      if (f[t] == 2) {
        s = t;
      }
    }
    add(a[i]);
    if (i <= n - 3) ret = max(ret, a[i] | s);
  }
  printf("%d\n", ret);
}
int main() {
  int TestCase = 1;
  while (TestCase--) {
    work();
  }
  return 0;
}
