#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
int n;
int a[N];
int first[N], last[N];
int vis[N];
int pre[N][N];
int dp[N];
int solve(int idx) {
  if (idx > n) return 0;
  if (dp[idx] != -1) return dp[idx];
  int ans = solve(idx + 1);
  if (first[a[idx]] == idx) {
    int l = first[a[idx]];
    int r = last[a[idx]];
    for (int i = idx + 1; i <= n; i++) {
      if (i > r) break;
      r = max(r, last[a[i]]);
      l = min(l, first[a[i]]);
    }
    if (l == idx) ans = max(ans, pre[idx][r] + solve(r + 1));
  }
  return dp[idx] = ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) last[a[i]] = i;
  for (int i = n; i >= 1; i--) first[a[i]] = i;
  for (int i = 1; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    int x = 0;
    for (int j = i; j <= n; j++) {
      if (!vis[a[j]]) {
        x ^= a[j];
        vis[a[j]] = 1;
      }
      pre[i][j] = x;
    }
  }
  memset(dp, -1, sizeof(dp));
  printf("%d", solve(1));
  return 0;
}
