#include <bits/stdc++.h>
using namespace std;
inline int get() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
int a[10005], b[10005], vst[5005], l[5005], r[5005], f[5005];
int n;
int main() {
  n = get();
  for (int i = 0; i <= 5000; i++) l[i] = 5001, r[i] = 0;
  for (int i = 1; i <= n; i++)
    a[i] = get(), l[a[i]] = min(l[a[i]], i), r[a[i]] = max(r[a[i]], i);
  for (int i = 1; i <= n; i++) {
    f[i] = f[i - 1];
    int q = l[a[i]], p = a[i];
    for (int j = 0; j <= 5000; j++) vst[j] = 0;
    vst[a[i]] = 1;
    for (int j = i; j >= q; j--) {
      if (r[a[j]] > i) break;
      q = min(q, l[a[j]]);
      if (!vst[a[j]]) vst[a[j]] = 1, p ^= a[j];
      if (j == q) f[i] = max(f[i], f[j - 1] + p);
    }
  }
  cout << f[n];
  return 0;
}
