#include <bits/stdc++.h>
const int maxn = 5e3 + 10;
const int N = 2e5 + 10;
using namespace std;
int id(int l, int r) { return l + r | l != r; }
long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }
long long qpow(long long p, long long q) {
  long long f = 1;
  while (q) {
    if (q & 1) f = f * p % 1000000007;
    p = p * p % 1000000007;
    q >>= 1;
  }
  return f;
}
int n, m, k, t, dp[maxn], a[maxn], st[maxn], ed[maxn], cnt[maxn];
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) ed[a[i]] = i;
  for (i = n; i >= 1; i--) st[a[i]] = i;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= i - 1; j++) dp[i] = max(dp[i], dp[j]);
    if (ed[a[i]] != i) continue;
    int mi = st[a[i]], p = 0;
    for (j = i; j >= mi; j--) {
      if (ed[a[j]] == j)
        p ^= a[j];
      else if (cnt[a[j]] != i)
        break;
      cnt[a[j]] = i;
      mi = min(mi, st[a[j]]);
    }
    if (j < mi) dp[i] = max(dp[i], p + dp[j]);
  }
  printf("%d\n", dp[n]);
  return 0;
}
