#include <bits/stdc++.h>
char ch;
bool fs;
void re(int& x) {
  while (ch = getchar(), ch < 33)
    ;
  if (ch == '-')
    fs = 1, x = 0;
  else
    fs = 0, x = ch - 48;
  while (ch = getchar(), ch > 33) x = x * 10 + ch - 48;
  if (fs) x = -x;
}
using namespace std;
int n, f[5555], a[5555], l[5555], r[5555];
int main() {
  re(n);
  for (int i = 1; i <= n; ++i) {
    re(a[i]);
    if (!l[a[i]]) l[a[i]] = i;
    r[a[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    f[i] = f[i - 1];
    int now = 0, le = i, re = i;
    for (int j = i; j >= le; --j) {
      le = min(le, l[a[j]]);
      re = max(re, r[a[j]]);
      if (l[a[j]] == j) now ^= a[j];
    }
    if (re == i) f[i] = max(f[i], f[le - 1] + now);
  }
  printf("%d\n", f[n]);
}
