#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline long long toll(string s) {
  long long v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
long long memo[5010];
int isStart[5010];
int isEnd[5010];
int vis[5010];
int visss[5010][5010];
vector<int> v;
int n;
long long solve(int i) {
  if (i == n) {
    return 0;
  }
  if (memo[i] != -1) {
    return memo[i];
  }
  int viss[5010];
  for (int j = 0; j < 5010; j++) {
    viss[j] = 0;
  }
  long long take = 0;
  int curEnd = 0;
  long long res = solve(i + 1);
  if (isStart[i]) {
    return memo[i] = res;
  } else {
    for (int j = i; j < n; j++) {
      curEnd = max(isEnd[j], curEnd);
      if (!viss[v[j]]) {
        take = take ^ v[j];
      }
      if (visss[i][v[j]] == 1) {
        res = max(res, solve(j + 1));
        break;
      }
      viss[v[j]] = 1;
      if (j >= curEnd) {
        res = max(res, take + solve(j + 1));
      }
    }
    return memo[i] = res;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    v.push_back(t);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      visss[i][v[j]] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (v[j] == v[i]) {
        isEnd[i] = j;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (vis[v[i]]) {
      isStart[i] = 1;
    }
    vis[v[i]] = 1;
  }
  memset(memo, -1, sizeof(memo));
  for (int i = 0; i < 5010; i++) {
    memo[i] = -1;
    vis[i] = 0;
  }
  cout << solve(0) << endl;
  ;
  return 0;
}
