#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int mod = 1000000007;
const double pi = acos(-1.0);
inline void gn(long long& x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (sg = -1, x = 0) : (x = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
inline void gn(int& x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(unsigned long long& x) {
  long long t;
  gn(t);
  x = t;
}
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
long long powmod(long long a, long long x, long long mod) {
  long long t = 1ll;
  while (x) {
    if (x & 1) t = t * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return t;
}
const int maxn = 5555;
int v[maxn], val[maxn][maxn], l[maxn], r[maxn];
bool vis[maxn];
int dp[maxn];
int main() {
  for (int i = (0); i <= (5000); i++) l[i] = r[i] = -1;
  int n;
  gn(n);
  for (int i = (1); i <= (n); i++) {
    gn(v[i]);
    if (l[v[i]] == -1) l[v[i]] = i;
    r[v[i]] = i;
  }
  for (int i = (1); i <= (n); i++) {
    memset((vis), 0, sizeof(vis));
    int now = 0, outl = 0, outr = 0;
    for (int j = (i); j <= (n); j++) {
      if (!vis[v[j]]) now ^= v[j];
      if (l[v[j]] < i) outl++;
      if (r[v[j]] > j && !vis[v[j]]) outr++;
      if (r[v[j]] == j && l[v[j]] != j) outr--;
      if (outl || outr)
        val[i][j] = 0;
      else
        val[i][j] = now;
      vis[v[j]] = true;
    }
  }
  for (int i = (1); i <= (n); i++) {
    for (int j = (0); j <= (i); j++) {
      dp[i] = max(dp[i], dp[j] + val[j + 1][i]);
    }
  }
  int ans = 0;
  for (int i = (1); i <= (n); i++) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}
