#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
const long long MOD = 1e9 + 7;
int a[5005], b[5005], last[5005], first[5005], n;
int vals[5005];
int mem[5005];
int solve(int idx) {
  if (idx == n) return 0;
  int &ret = mem[idx];
  if (ret != -1) return ret;
  ret = solve(idx + 1);
  if (idx == first[a[idx]] && vals[idx] > -1)
    ret = max(vals[idx] + solve(last[idx] + 1), ret);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  memset(first, 6000, sizeof first);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[a[i]]++;
    first[a[i]] = min(first[a[i]], i);
  }
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    if (i == first[a[i]]) {
      mp.clear();
      int val = 0, ok = 0, j = i;
      while (j < n) {
        if (mp[a[j]])
          mp[a[j]]++;
        else {
          mp[a[j]] = 1;
          val = val ^ a[j];
        }
        ok += (mp[a[j]] == b[a[j]]);
        if (ok == mp.size()) break;
        j++;
      }
      if (ok == mp.size()) {
        vals[i] = val;
        last[i] = j;
      } else {
        vals[i] = -1;
      }
    }
  }
  memset(mem, -1, sizeof mem);
  cout << solve(0);
}
