#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 7;
int a[maxn], st[maxn], ed[maxn], b[maxn], f[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    if (!st[a[i]]) st[a[i]] = i;
    ed[a[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    memset(b, 0, sizeof(b));
    f[i] = f[i - 1];
    int l = i, r = i, t = 0;
    for (int j = i; j >= 1; --j) {
      l = min(l, st[a[j]]), r = max(r, ed[a[j]]);
      if (!b[a[j]]) {
        b[a[j]] = 1;
        t ^= a[j];
      }
      if (r > i) break;
      if (l == j) f[i] = max(f[i], f[j - 1] + t);
    }
  }
  printf("%d\n", f[n]);
  return 0;
}
