#include <bits/stdc++.h>
using namespace std;
int a[1000010], f[1 << 23];
void updata(int x, int d) {
  if (f[x] >= 2) return;
  if (d == -1) {
    f[x]++;
    return;
  }
  updata(x, d - 1);
  if (x & (1 << d)) updata(x ^ (1 << d), d - 1);
}
int query(int x) {
  int ans = 0;
  for (int i = 22; i >= 0; i--) {
    if ((x & (1 << i)) == 0 && (f[ans | (1 << i)] >= 2)) ans |= 1 << i;
  }
  return x | ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  for (int i = n; i; i--) {
    if (i <= n - 2) ans = max(ans, query(a[i]));
    updata(a[i], 22);
  }
  printf("%d\n", ans);
}
