#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
inline T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return a * (b / gcd(a, b));
}
vector<int> arr;
const int N = 50005;
int memo[5001];
int save[N];
int visit[N];
int find(int pos, int &xr) {
  for (int i = 0; i < N; i++) visit[i] = 0;
  vector<int> toAdd;
  int end = pos;
  visit[arr[pos]] = 1;
  for (int i = 0; i < pos; i++) {
    visit[arr[i]] = 2;
  }
  if (visit[arr[pos]] == 2) {
    return -1;
  }
  bool cant = false;
  for (int i = pos; i < arr.size(); i++) {
    if (visit[arr[i]] == 2) {
      cant = true;
    }
    if (visit[arr[i]] == 1) {
      if (cant) return -1;
      for (int j = 0; j < toAdd.size(); j++) {
        visit[toAdd[j]] = 1;
      }
      toAdd.clear();
      end = i;
    } else {
      toAdd.push_back(arr[i]);
    }
  }
  xr = 0;
  for (int i = 0; i < N; i++) {
    if (visit[i] == 1) {
      xr = xr ^ i;
    }
  }
  return end;
}
int solve(int from) {
  int txr = 0;
  int ret = 0;
  if (from >= arr.size()) return 0;
  if (memo[from] != -1) {
    return memo[from];
  }
  int end = find(from, txr);
  if (end != -1) {
    ret = max(txr + solve(end + 1), solve(from + 1));
  } else {
    ret = solve(from + 1);
  }
  memo[from] = ret;
  return ret;
}
int main() {
  int n, i, temp, j;
  for (i = (int)0; i < (int)5001; ++i) {
    memo[i] = -1;
  }
  scanf("%d", &n);
  for (i = (int)0; i < (int)n; ++i) {
    scanf("%d", &temp);
    arr.push_back(temp);
  }
  int xx;
  cout << solve(0);
  return 0;
}
