#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 5e3 + 100;
int N, a[MAXN], l[MAXN], r[MAXN], memo[MAXN];
int f(int i) {
  if (i == N) {
    return 0;
  }
  if (memo[i] != -1) {
    return memo[i];
  }
  int ans = f(i + 1);
  int cur_r = r[i];
  int cur = 0;
  vector<bool> used(MAXN, false);
  for (int j = i; j < N; j++) {
    if (l[j] < i) break;
    if (!used[a[j]]) {
      used[a[j]] = true;
      cur ^= a[j];
    }
    cur_r = max(cur_r, r[j]);
    if (j == cur_r) {
      ans = max(ans, cur + f(j + 1));
    }
  }
  memo[i] = ans;
  return ans;
}
void solve() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      if (a[i] == a[j]) {
        r[i] = j;
      }
    }
    for (int j = i; j >= 0; j--) {
      if (a[i] == a[j]) {
        l[i] = j;
      }
    }
  }
  memset(memo, -1, sizeof(memo));
  cout << f(0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
