#include <bits/stdc++.h>
using namespace std;
template <typename G>
inline void read(G &x) {
  x = 0;
  char c;
  while (!isdigit(c = getchar()))
    ;
  do {
    x = x * 10 + c - '0';
  } while (isdigit(c = getchar()));
}
template <typename G>
inline void write(G x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
inline T min(T a, T b, T c, T d) {
  return min(a, min(b, c, d));
}
template <class T>
inline T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
inline T max(T a, T b, T c, T d) {
  return max(a, max(b, c, d));
}
const int MAXN = 1e5 * 5;
const int base = 1e9 + 7;
const int N = 5000 + 50;
int n, ans;
int a[N], g[N][N], f[N], cnt[N];
int st[N], en[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  int mx = 0;
  for (int i = (1); i <= (n); ++i) cin >> a[i], mx = max(mx, a[i]);
  for (int l = (1); l <= (n); ++l) {
    for (int i = (0); i <= (mx); ++i) cnt[i] = 0;
    g[l][l] = a[l];
    cnt[a[l]] = 1;
    for (int r = (l + 1); r <= (n); ++r) {
      g[l][r] = cnt[a[r]] == 1 ? g[l][r - 1] : g[l][r - 1] ^ a[r];
      cnt[a[r]] = 1;
    }
  }
  for (int i = (0); i <= (mx); ++i) cnt[i] = 0;
  for (int i = (1); i <= (n); ++i)
    if (!cnt[a[i]]) {
      cnt[a[i]] = 1;
      st[a[i]] = i;
    }
  for (int i = (0); i <= (mx); ++i) cnt[i] = 0;
  for (int i = (n); i >= (1); --i)
    if (!cnt[a[i]]) {
      cnt[a[i]] = 1;
      en[a[i]] = i;
    }
  for (int i = (1); i <= (n); ++i) {
    f[i] = f[i - 1];
    if (i == en[a[i]]) {
      int k = st[a[i]];
      int j = i;
      int ok = 0;
      while (j >= k) {
        k = min(k, st[a[j]]);
        if (en[a[j]] > i) {
          ok = 1;
          break;
        }
        --j;
      }
      if (ok) continue;
      f[i] = max(f[i], f[k - 1] + g[k][i]);
    }
  }
  cout << f[n] << '\n';
  return 0;
}
