#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 3;
int n, a[MAXN];
long long pre[MAXN], mem[MAXN];
int l[MAXN], r[MAXN], fin[MAXN];
long long dp(int x) {
  if (x == n) return 0;
  long long &ret = mem[x];
  if (ret != -1) return ret;
  ret = dp(x + 1);
  if (pre[x] != -1) ret = max(ret, pre[x] + dp(fin[x]));
  return ret;
}
int main() {
  memset(pre, -1, sizeof pre);
  memset(mem, -1, sizeof mem);
  scanf("%d", &n);
  for (int i = 0; i < MAXN; ++i) {
    l[i] = MAXN;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    l[a[i]] = min(l[a[i]], i);
    r[a[i]] = i + 1;
  }
  for (int i = 0; i < n; ++i) {
    if (l[a[i]] != i) continue;
    int right = r[a[i]];
    set<int> s;
    bool ok = 1;
    for (int j = i; j < right && ok; ++j) {
      s.insert(a[j]);
      if (l[a[j]] < i) ok = 0;
      right = max(right, r[a[j]]);
    }
    int curr = 0;
    for (auto j : s) {
      curr ^= j;
    }
    if (ok) {
      pre[i] = curr;
      fin[i] = right;
    }
  }
  printf("%lld\n", dp(0));
  return 0;
}
