#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int data[maxn], val[maxn], tol[maxn], tor[maxn], n;
int seg[maxn << 2];
void modify(int p, int v, int l, int r, int rt) {
  if (l == r) {
    seg[rt] = v;
    return;
  }
  int m = (l + r) >> 1;
  if (p <= m)
    modify(p, v, l, m, rt << 1);
  else
    modify(p, v, m + 1, r, rt << 1 | 1);
  seg[rt] = max(seg[rt << 1], seg[rt << 1 | 1]);
}
void modifymi(int p, int v, int l, int r, int rt) {
  if (l == r) {
    seg[rt] = v;
    return;
  }
  int m = (l + r) >> 1;
  if (p <= m)
    modifymi(p, v, l, m, rt << 1);
  else
    modifymi(p, v, m + 1, r, rt << 1 | 1);
  seg[rt] = min(seg[rt << 1], seg[rt << 1 | 1]);
}
int querymi(int ll, int rr, int l, int r, int rt) {
  if (ll <= l && r <= rr) return seg[rt];
  int m = (l + r) >> 1, res = n + 1;
  if (ll <= m) res = min(res, querymi(ll, rr, l, m, rt << 1));
  if (rr > m) res = min(res, querymi(ll, rr, m + 1, r, rt << 1 | 1));
  return res;
}
int query(int ll, int rr, int l, int r, int rt) {
  if (ll <= l && r <= rr) return seg[rt];
  int m = (l + r) >> 1, res = 0;
  if (ll <= m) res = max(res, query(ll, rr, l, m, rt << 1));
  if (rr > m) res = max(res, query(ll, rr, m + 1, r, rt << 1 | 1));
  return res;
}
void build(int l, int r, int rt) {
  seg[rt] = n + 1;
  if (l == r) return;
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
}
map<int, int> mp;
map<int, int>::iterator it;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", data + i);
    mp[data[i]];
  }
  it = mp.begin();
  for (int i = 1; i <= n; i++) {
    it->second = i;
    it++;
  }
  for (int i = 1; i <= n; i++) val[i] = mp[data[i]];
  for (int i = 1; i <= n; i++) {
    tol[i] = query(val[i], n, 1, n, 1);
    modify(val[i], i, 1, n, 1);
  }
  build(1, n, 1);
  for (int i = n; i >= 1; i--) {
    tor[i] = querymi(val[i], n, 1, n, 1);
    modifymi(val[i], i, 1, n, 1);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (tol[i]) ans = max(ans, data[i] ^ (data[tol[i]]));
    if (tor[i] != n + 1) ans = max(ans, data[i] ^ (data[tor[i]]));
  }
  printf("%d\n", ans);
}
