#include <bits/stdc++.h>
using namespace std;
long a[5001], l[5001], r[5001], zabo[5001], dp[5001], pocetak[5001];
int main() {
  long n, i, t, ok, txor, j;
  scanf("%ld", &n);
  for (i = 1; i <= n; i++) scanf("%ld", &a[i]);
  for (i = 1; i <= n; i++) {
    if (l[a[i]] == 0) l[a[i]] = i;
    r[a[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    if (l[a[i]] < i) continue;
    t = r[a[i]];
    ok = 1;
    txor = 0;
    for (j = i; j <= t; j++) {
      if (r[a[j]] == j) txor ^= a[j];
      if (r[a[j]] > t) t = r[a[j]];
      if (l[a[j]] < i) {
        ok = 0;
        break;
      }
    }
    if (zabo[t] == 0) {
      zabo[t] = ok * txor;
      pocetak[t] = i;
    }
  }
  dp[0] = 0;
  for (i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    if (zabo[i]) dp[i] = max(dp[i], zabo[i] + dp[pocetak[i] - 1]);
  }
  printf("%ld", dp[n]);
  return 0;
}
