#include <bits/stdc++.h>
using namespace std;
template <class C>
void min_self(C &a, C b) {
  a = min(a, b);
}
template <class C>
void max_self(C &a, C b) {
  a = max(a, b);
}
long long mod(long long n, long long m = 1000000007) {
  n %= m, n += m, n %= m;
  return n;
}
const int MAXN = (1 << 21);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int n;
vector<pair<int, int>> store;
vector<int> a(MAXN);
void init() {
  store.resize(MAXN + 2);
  for (int i = 0; i < MAXN; i++) store[i] = {-1, -1};
}
void update(pair<int, int> &p, int ind) {
  if (ind > p.first) {
    p.second = p.first;
    p.first = ind;
  } else
    p.second = max(p.second, ind);
}
bool check(int mask, int done) {
  for (int i = 0; i < n; i++) {
    int rem = (a[i] ^ mask) & done;
    if (store[rem].second > i) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  init();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    update(store[a[i]], i);
  }
  for (int bit = 0; bit < 21; bit++) {
    for (int i = 0; i < MAXN; i++) {
      if (i & (1 << bit)) {
        update(store[i ^ (1 << bit)], store[i].first);
        update(store[i ^ (1 << bit)], store[i].second);
      }
    }
  }
  int mask = 0, done = 0;
  for (int bit = 20; bit >= 0; bit--) {
    int submask = (1 << bit);
    done += submask;
    if (check(mask + submask, done)) {
      mask += submask;
    }
  }
  cout << mask, cout << "\n";
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
