#include <bits/stdc++.h>
using namespace std;
const int N = 5678;
int n, a[N], last[N], dp[N], first[N];
bool can;
set<int> st, real_st;
vector<pair<int, int> > ans;
int rec(int x) {
  if (x >= n) return 0;
  if (dp[x] != -1) return dp[x];
  int take = -1e9;
  if (first[a[x]] == x) take = rec(ans[x].first + 1) + ans[x].second;
  int dont = rec(x + 1);
  return dp[x] = max(dont, take);
}
int main() {
  cin >> n;
  ans.resize(n + 1);
  for (int i = 0; i < n; i++) ans[i] = make_pair(i, -1e9);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  memset(last, -1, sizeof(last));
  memset(first, -1, sizeof(first));
  memset(dp, -1, sizeof(dp));
  for (int i = n - 1; i >= 0; i--)
    if (last[a[i]] == -1) last[a[i]] = i;
  for (int i = 0; i < n; i++)
    if (first[a[i]] == -1) first[a[i]] = i;
  for (int i = 0; i < n; i++) {
    if (real_st.count(a[i])) continue;
    real_st.insert(a[i]);
    int final = last[a[i]], xr = 0;
    st.clear();
    can = true;
    for (int j = i; j <= final; j++) {
      if (st.count(a[j])) continue;
      st.insert(a[j]);
      xr ^= a[j];
      if (first[a[j]] < i) can = false;
      final = max(final, last[a[j]]);
    }
    if (!can) xr = -1e9;
    ans[i] = make_pair(final, xr);
  }
  cout << rec(0);
}
