#include <bits/stdc++.h>
using namespace std;
inline int geti() {
  register int c = getchar(), first = 0;
  for (; c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  return first;
}
template <class T>
inline T sq(T first) {
  return first * first;
}
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const long long MOD = 1000000007LL;
const double pi = acos(-1.0);
const int MAXN = 5e3 + 5;
int C[MAXN], A[MAXN], dp[MAXN], vis[MAXN], N;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
    C[A[i]]++;
  }
  for (int i = 1; i <= N; ++i) {
    memset(vis, 0, sizeof(vis));
    int sum = 0, num = 0;
    for (int j = i; j >= 1;) {
      if (!vis[A[j]]) vis[A[j]] = 1, num += C[A[j]], sum ^= A[j];
      --num, --j;
      dp[i] = max(dp[i], dp[j] + (num ? 0 : sum));
    }
  }
  printf("%d\n", dp[N]);
  return 0;
}
