#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 11;
int n;
int arr[MAXN];
int cnt[MAXN];
bool vis[MAXN];
long long DP[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", arr + i);
    ++cnt[arr[i]];
  }
  for (int i = 1; i <= n; ++i) {
    int tmp = 0, cur = 0;
    memset(vis, 0, sizeof vis);
    for (int j = i; j >= 1; --j) {
      if (!vis[arr[j]]) tmp += cnt[arr[j]], cur ^= arr[j], vis[arr[j]] = true;
      DP[i] = max(DP[i], DP[j - 1] + (--tmp ? 0 : cur));
    }
  }
  printf("%I64d", DP[n]);
  return 0;
}
