#include <bits/stdc++.h>
using namespace std;
int A[5005];
long long dp[6000];
int xr[5050];
int used[5055];
int leastPos[5050];
int maxPos[5455];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", A + i);
  }
  dp[0] = 0;
  xr[0] = 0;
  memset(leastPos, -1, sizeof(leastPos));
  memset(maxPos, -1, sizeof(maxPos));
  for (int i = 1; i <= N; i++) {
    if (leastPos[A[i]] == -1) leastPos[A[i]] = i;
    if (leastPos[A[i]] == i)
      xr[i] = xr[i - 1] ^ A[i];
    else
      xr[i] = xr[i - 1];
  }
  for (int i = N; i >= 1; i--) {
    if (maxPos[A[i]] == -1) maxPos[A[i]] = i;
  }
  dp[N + 1] = 0;
  for (int i = N; i >= 1; i--) {
    dp[i] = dp[i + 1];
    int least = leastPos[A[i]];
    int high = maxPos[A[i]];
    memset(used, 0, sizeof(used));
    int t = 0;
    for (int j = i; j <= N; j++) {
      least = min(leastPos[A[j]], least);
      high = max(high, maxPos[A[j]]);
      if (least < i) break;
      if (!used[A[j]]) t ^= A[j], used[A[j]] = 1;
      if (high == j)
        dp[i] = max(dp[i], (xr[high] ^ xr[least - 1]) + dp[high + 1]);
    }
  }
  printf("%lld\n", dp[1]);
}
