#include <bits/stdc++.h>
using namespace std;
const long long N = 5e3 + 1;
long long dp[N];
long long l[N], r[N];
long long a[N];
long long n;
long long solve(long long idx) {
  if (idx == n + 1) return 0;
  if (dp[idx] != -1) return dp[idx];
  long long ans = 0;
  long long first = l[a[idx]];
  long long last = r[a[idx]];
  if (first < idx) {
    ans = solve(idx + 1);
  } else {
    set<long long> st;
    long long newfirst = first;
    long long newlast = last;
    long long xorr = 0;
    for (long long i = idx; i <= last; i++) {
      newfirst = min(newfirst, l[a[i]]);
      newlast = max(newlast, r[a[i]]);
      if (st.find(a[i]) == st.end()) {
        st.insert(a[i]);
        xorr ^= a[i];
      }
    }
    if (newfirst < idx) {
      ans = solve(idx + 1);
    } else {
      ans = max(solve(idx + 1), xorr + solve(newlast + 1));
    }
  }
  dp[idx] = ans;
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (l[a[i]] == 0) {
      l[a[i]] = i;
      r[a[i]] = i;
    } else
      r[a[i]] = i;
  }
  cout << solve(1);
}
