#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N], n;
int fun(int st, int ed, int mx, bool flag) {
  int ans = 0;
  priority_queue<int> que;
  if (flag == 0) {
    for (int i = st; i <= ed; i++) {
      que.push(a[i]);
      ans = max(ans, mx ^ que.top());
    }
  } else {
    for (int i = st; i >= ed; i--) {
      que.push(a[i]);
      ans = max(ans, mx ^ que.top());
    }
  }
  return ans;
}
int getans(int mx) {
  vector<int> pos;
  for (int i = 0; i < n; i++) {
    if (a[i] & (1 << mx)) {
      pos.push_back(i);
    }
  }
  if (pos.size() == 0) return 0;
  int ans = 0;
  pos.push_back(n);
  for (int i = 0; i < (int)pos.size(); i++) {
    if (i == 0) {
      ans = max(ans, fun(pos[0] + 1, pos[1] - 1, a[pos[i]], 0));
      ans = max(ans, fun(pos[0] - 1, 0, a[pos[i]], 1));
    } else if (i == (int)pos.size() - 1) {
      ans = max(ans, fun(pos[i] + 1, n - 1, a[pos[i]], 0));
      ans = max(ans, fun(pos[i] - 1, pos[i - 1] + 1, a[pos[i]], 1));
    } else {
      ans = max(ans, fun(pos[i] + 1, pos[i + 1] - 1, a[pos[i]], 0));
      ans = max(ans, fun(pos[i] - 1, pos[i - 1] + 1, a[pos[i]], 1));
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] & (1 << mx)) {
      a[i] ^= (1 << mx);
    }
  }
  return ans;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    int mx = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      int tmp = a[i], cnt = 0;
      while (tmp) {
        tmp /= 2;
        cnt++;
      }
      mx = max(mx, cnt);
    }
    int ans = 0;
    for (int i = mx - 1; i >= 0; i--) {
      ans = max(ans, getans(i));
      if (ans) break;
    }
    cout << ans << endl;
  }
  return 0;
}
