#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 1;
int val[N][N];
int first[N], last[N];
int n, a[N], memo[N];
int go(int i) {
  if (i == n) return 0;
  if (memo[i] != -1) return memo[i];
  int ret = go(i + 1);
  if (first[a[i]] == i) {
    ret = max(ret, go(last[a[i]] + 1) + val[first[a[i]]][last[a[i]]]);
  }
  return memo[i] = ret;
}
int main() {
  scanf("%d", &n);
  memset(first, -1, sizeof first);
  memset(last, -1, sizeof last);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    if (first[a[i]] == -1) {
      first[a[i]] = i, last[a[i]] = i;
    } else {
      last[a[i]] = i;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (first[a[i]] != i || last[a[i]] == i) continue;
    vector<int> in;
    for (int j = i + 1; j < n; ++j) {
      if (last[a[i]] == j) {
        for (auto x : in) {
          first[a[i]] = min(first[a[i]], first[x]);
          last[a[i]] = max(last[a[i]], last[x]);
        }
        break;
      }
      in.push_back(a[j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    int v = 0;
    bool vis[N] = {};
    for (int j = i; j < n; ++j) {
      if (!vis[a[j]]++) v ^= a[j];
      val[i][j] = v;
    }
  }
  memset(memo, -1, sizeof memo);
  printf("%d\n", go(0));
  return 0;
}
