#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const int MAX = 5e3 + 10;
bool has[MAX];
int trans[MAX][MAX], memo[MAX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int& i : v) cin >> i;
  vector<pair<int, int>> vmp(MAX, {INF, -INF});
  for (int i = 0; i < n; i++) {
    vmp[v[i]].first = min(vmp[v[i]].first, i);
    vmp[v[i]].second = i;
  }
  memset(trans, -1, sizeof trans);
  for (int i = 0; i < n; i++) {
    memset(has, 0, sizeof has);
    int curr = 0;
    pair<int, int> p(INF, -INF);
    for (int j = i; j < n; j++) {
      if (!has[v[j]]) curr ^= v[j];
      has[v[j]] = 1;
      p.first = min(p.first, vmp[v[j]].first),
      p.second = max(p.second, vmp[v[j]].second);
      if (p.first >= i and p.second <= j) trans[i][j] = curr;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    int now = memo[i + 1];
    for (int j = i; j < n; j++)
      if (trans[i][j] != -1) now = max(now, trans[i][j] + memo[j + 1]);
    memo[i] = now;
  }
  cout << memo[0] << '\n';
  return 0;
}
