#include <bits/stdc++.h>
using namespace std;
const long long N = 111111;
long long n, a[N];
vector<long long> st;
struct node {
  node* nxt[2];
  long long pref;
  node() {
    fill(nxt, nxt + 2, nullptr);
    pref = 0;
  }
};
node* root = new node();
void add(long long x) {
  node* v = root;
  for (long long i = 31; i >= 0; i--) {
    bool y = x & (1ll << i);
    if (v->nxt[y] == nullptr) v->nxt[y] = new node();
    v = v->nxt[y];
    v->pref++;
  }
}
void del(long long x) {
  node* v = root;
  for (long long i = 31; i >= 0; i--) {
    bool y = x & (1ll << i);
    v = v->nxt[y];
    v->pref--;
  }
}
long long f(long long x) {
  node* v = root;
  long long r = 0;
  for (long long i = 31; i >= 0; i--) {
    bool y = x & (1ll << i);
    if (v->nxt[!y] != nullptr && v->nxt[!y]->pref) {
      r += (1ll << i);
      v = v->nxt[!y];
    } else {
      v = v->nxt[y];
    }
  }
  return r;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(40);
  cin >> n;
  for (long long i = 0; i < n; ++i) cin >> a[i];
  long long res = 0;
  for (long long i = 0; i < n; ++i) {
    while (st.size() && st.back() < a[i]) {
      res = max(res, st.back() ^ a[i]);
      del(st.back());
      st.pop_back();
    }
    st.push_back(a[i]);
    add(a[i]);
  }
  while (st.size()) {
    del(st.back());
    st.pop_back();
  }
  reverse(a, a + n);
  for (long long i = 0; i < n; ++i) {
    while (st.size() && st.back() < a[i]) {
      res = max(res, st.back() ^ a[i]);
      del(st.back());
      st.pop_back();
    }
    st.push_back(a[i]);
    add(a[i]);
  }
  cout << res;
}
