#include <bits/stdc++.h>
using namespace std;
bool ne(const deque<int> &v, int a, int b) {
  deque<int>::const_iterator it = lower_bound((v).begin(), (v).end(), a);
  return it != v.end() && *it <= b;
}
int comp(const vector<int> &p) {
  int res = 0;
  deque<int> S;
  for (__typeof((p).begin()) it = (p).begin(); it != (p).end(); ++it) {
    int t = 0, xt = 0;
    for (int i = 30; i >= 0; --i) {
      int tmp;
      if (*it & (1 << i)) {
        tmp = xt;
        xt = xt + (1 << i);
      } else {
        tmp = xt + (1 << i);
      }
      if (ne(S, tmp, min(tmp + (1 << i) - 1, *it))) {
        t |= (1 << i);
        xt = tmp;
      }
    }
    res = max(res, t);
    while (!S.empty() && S.front() <= *it) {
      S.pop_front();
    }
    S.push_front(*it);
  }
  return res;
}
int main(void) {
  int n;
  scanf("%d", &n);
  vector<int> s(n);
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &s[i]);
  }
  int res = comp(s);
  reverse((s).begin(), (s).end());
  res = max(res, comp(s));
  printf("%d\n", res);
  return 0;
}
