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