#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, a[500005], c = -1, d, k = 1, ans, k1;
pair<int, int> p[500005];
stack<int> st;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= n; i++) {
    p[i].first = -1;
    while (!st.empty()) {
      if (st.top() <= a[i])
        st.pop();
      else {
        break;
      }
    }
    if (!st.empty()) {
      p[i].first = st.top();
    }
    st.push(a[i]);
  }
  while (!st.empty()) st.pop();
  for (i = n; i >= 1; i--) {
    p[i].second = -1;
    while (!st.empty()) {
      if (st.top() <= a[i])
        st.pop();
      else {
        break;
      }
    }
    if (!st.empty()) {
      p[i].second = st.top();
    }
    st.push(a[i]);
  }
  for (i = 1; i <= n; i++) {
    c = d = 0;
    if (p[i].first != -1) c = a[i] ^ p[i].first;
    if (p[i].second != -1) d = a[i] ^ p[i].second;
    ans = max(ans, max(c, d));
  }
  printf("%d\n", ans);
  return 0;
}
