#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e6 + 3;
const int MAXN = 5010;
int n, d[MAXN], vis[MAXN], a[MAXN], L[MAXN], R[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    if (!L[a[i]])
      L[a[i]] = R[a[i]] = i;
    else
      R[a[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    d[i] = d[i - 1];
    if (R[a[i]] != i) continue;
    int l = L[a[i]], res = a[i];
    vis[a[i]] = i;
    bool flag = true;
    for (int j = i - 1; j >= l; --j) {
      if (vis[a[j]] == i) continue;
      if (R[a[j]] > i) {
        flag = false;
        break;
      }
      l = min(L[a[j]], l);
      res ^= a[j];
      vis[a[j]] = i;
    }
    if (flag) d[i] = max(d[i], d[l - 1] + res);
  }
  printf("%d\n", d[n]);
  return 0;
}
