#include <bits/stdc++.h>
namespace cat888 {
inline void check_min(int a, int &b) {
  if (a < b) b = a;
}
inline void check_max(int a, int &b) {
  if (a > b) b = a;
}
const int N = 5050;
int s[N], f[N], w[N], cnt[N];
bool vis[N];
int n;
void gotin() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", s + i), cnt[s[i]]++;
}
void solve() {
  gotin();
  for (int i = 1, need; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    need = 0;
    for (int j = i, ret = 0; j; j--) {
      if (!vis[s[j]]) need += cnt[s[j]], ret ^= s[j], vis[s[j]] = 1;
      need--;
      if (need == 0) {
        check_max(f[j - 1] + ret, f[i]);
        break;
      }
    }
    check_max(f[i - 1], f[i]);
  }
  printf("%d\n", f[n]);
}
}  // namespace cat888
int main() {
  cat888::solve();
  return 0;
}
