#include <bits/stdc++.h>
using namespace std;
int a[1000005], n, dp[1 << 21][21];
void upd(int num, int b = 20) {
  if (b < 0 || dp[num][b] > 1) return;
  ++dp[num][b];
  upd(num, b - 1);
  if (num >> b & 1) upd(num ^ (1 << b), b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; cin >> a[i++])
    ;
  int ans = 0;
  for (int i = n; i > 0; upd(a[i--])) {
    int now = 0, req = 0;
    for (int b = 21; b--;)
      if (a[i] >> b & 1)
        now |= 1 << b;
      else if (dp[req | (1 << b)][0] > 1)
        now |= 1 << b, req |= 1 << b;
    if (i < n - 1) ans = max(ans, now);
  }
  cout << ans;
}
