#include <bits/stdc++.h>
using namespace std;
const int mx = 1123456, sigma = 2;
struct node {
  int c[sigma];
  int qtd;
  set<int> s;
  void init() {
    qtd = 0;
    memset(c, -1, sizeof c);
    s.clear();
  }
} trie[mx];
int z;
void init() { z = 0, trie[0].init(); }
inline void add(int x) {
  int cur = 0;
  for (int i = 30; ~i; i--) {
    bool bit = (x >> i) & 1;
    int &u = trie[cur].c[bit];
    if (u == -1) {
      u = ++z;
      trie[u].init();
    }
    if (trie[u].s.count(x))
      trie[u].s.erase(x);
    else
      trie[u].s.insert(x);
    cur = u;
  }
}
inline int query(int x) {
  int cur = 0, ans = 0;
  for (int i = 30; ~i; i--) {
    bool bit = (x >> i) & 1;
    bool f1 = 0, f2 = 0;
    if (~trie[cur].c[!bit]) {
      auto &s1 = trie[trie[cur].c[!bit]].s;
      if (!s1.empty()) {
        auto a1 = s1.lower_bound(x);
        f1 = (a1 != s1.begin()) && ((*prev(a1)) < x);
        if (f1) cur = trie[cur].c[!bit], ans |= (!bit) << i;
      }
    }
    if (!f1 && ~trie[cur].c[bit]) {
      auto &s2 = trie[trie[cur].c[bit]].s;
      if (!s2.empty()) {
        auto a2 = s2.lower_bound(x);
        f2 = (a2 != s2.begin()) && ((*prev(a2)) < x);
        if (f2) cur = trie[cur].c[bit], ans |= bit << i;
      }
    }
    if (!f1 && !f2) return x;
  }
  return ans;
}
int v[mx];
string bin(int x) { return (new bitset<32>(x))->to_string(); }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  vector<int> st;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    while (!st.empty() && v[i] > st.back()) {
      ans = max(ans, v[i] ^ st.back());
      st.pop_back();
    }
    st.push_back(v[i]);
  }
  st.clear();
  reverse(v, v + n);
  for (int i = 0; i < n; i++) {
    ans = max(ans, v[i] ^ query(v[i]));
    while (!st.empty() && v[i] > st.back()) {
      ans = max(ans, v[i] ^ st.back());
      st.pop_back();
    }
    st.push_back(v[i]);
  }
  cout << ans << endl;
}
