#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10001;
vector<int> pos[MAXN];
int arr[MAXN];
int L[MAXN], R[MAXN];
int dp[MAXN];
int n;
int go(int idx) {
  int &ret = dp[idx];
  if (idx == n + 1) return 0;
  if (ret != -1) return ret;
  int value = arr[idx];
  ret = 0;
  set<int> st;
  if (L[value] < idx) {
    ret = max(ret, go(idx + 1));
  } else {
    ret = max(ret, go(idx + 1));
    int l = idx, r = R[value];
    int xors = 0;
    for (int i = idx; i <= n; i++) {
      int value = arr[i];
      int prev = st.size();
      st.insert(value);
      int nxt = st.size();
      if (nxt > prev) {
        xors ^= value;
      }
      l = min(l, L[value]);
      r = max(r, R[value]);
      if (l == idx && r == i) {
        ret = max(ret, go(i + 1) + xors);
      }
    }
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    pos[arr[i]].push_back(i);
  }
  for (int i = 0; i <= 5000; i++) {
    if (pos[i].size()) {
      L[i] = pos[i].front();
      R[i] = pos[i].back();
    }
  }
  cout << go(1);
  return 0;
}
