#include <bits/stdc++.h>
using namespace std;
inline void smax(int &x, int y) { x = max(x, y); }
inline void smin(int &x, int y) { x = min(x, y); }
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%l64d", &x);
  return x;
}
const int MAXN = 5e3 + 10;
int aval[MAXN], akhar[MAXN], n, a[MAXN], dp[MAXN];
bool mark[MAXN];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    if (!aval[a[i]]) aval[a[i]] = i;
    akhar[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    memset(mark, 0, sizeof mark);
    int cur = a[i], mx = akhar[a[i]], mn = aval[a[i]];
    mark[a[i]] = 1;
    for (int j = i; j; j--) {
      smax(mx, akhar[a[j]]);
      smin(mn, aval[a[j]]);
      if (!mark[a[j]]) mark[a[j]] = 1, cur ^= a[j];
      if (mn <= i && mn >= j && mx <= i && mx >= j)
        smax(dp[i], dp[j - 1] + cur);
    }
  }
  cout << dp[n];
}
