#include <bits/stdc++.h>
using namespace std;
const int N = 4000005;
int n, cnt[N], ans, a[N];
void insert(int x, int y) {
  if (cnt[x | y] == 2) return;
  if (x == 0) {
    cnt[y]++;
    return;
  }
  insert(x - (x & -x), y | x & -x);
  insert(x - (x & -x), y);
}
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 + 2 <= n) {
      int now = 0;
      for (int j = 20; j >= 0; j--)
        if (!((1 << j) & a[i]) && cnt[now | 1 << j] == 2) now |= 1 << j;
      ans = max(ans, now | a[i]);
    }
    insert(a[i], 0);
  }
  printf("%d\n", ans);
  return 0;
}
