#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, arr[N], dp[N];
vector<vector<int> > vec(N);
bool in[N];
void clearVec(vector<int>& vec) {
  for (int i = 0; i < vec.size(); i++) in[vec[i]] = false;
}
int solve(int ind) {
  if (ind == n) return 0;
  if (dp[ind] != -1) return dp[ind];
  int ans = solve(ind + 1);
  int nextStart = ind;
  int currAns = 0;
  vector<int> s;
  while (nextStart < n) {
    if (vec[arr[nextStart]][0] == nextStart) {
      s.push_back(arr[nextStart]);
      in[arr[nextStart]] = true;
      currAns ^= arr[nextStart];
      int maxInd = vec[arr[nextStart]].back();
      bool failed = false;
      for (int i = nextStart + 1; i <= maxInd; i++) {
        if (vec[arr[i]][0] == i) {
          currAns ^= arr[i];
          in[arr[i]] = true;
          s.push_back(arr[i]);
          maxInd = max(maxInd, vec[arr[i]].back());
        } else if (!in[arr[i]]) {
          failed = true;
        }
      }
      if (failed) break;
      ans = max(ans, currAns + solve(maxInd + 1));
      nextStart = maxInd + 1;
    } else
      break;
  }
  clearVec(s);
  return dp[ind] = ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]), vec[arr[i]].push_back(i);
  memset(dp, -1, sizeof dp);
  printf("%d", solve(0));
  return 0;
}
