#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 10;
int n;
bool vis[maxn];
int a[maxn], cnt[maxn], f[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    ++cnt[a[i]];
  }
  for (int i = 1; i <= n; i++) {
    int need = 0, res = 0;
    memset(vis, 0, sizeof vis);
    for (int j = i; j;) {
      if (!vis[a[j]]) {
        vis[a[j]] = 1;
        need += cnt[a[j]];
        res ^= a[j];
      }
      --j;
      f[i] = max(f[i], f[j] + (--need ? 0 : res));
    }
  }
  printf("%d\n", f[n]);
  return 0;
}
