#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MAX = 5005;
int N;
vector<int> V;
vector<vector<pair<int, int>>> T;
int L[MAX];
int F[MAX];
void pre() {
  T.resize(N);
  for (int i = 0; i < N; i++) {
    L[V[i]] = i;
  }
  for (int i = N - 1; i >= 0; i--) {
    F[V[i]] = i;
  }
  for (int i = 0; i < N; i++) {
    int XOR = -1;
    int LAST = i;
    bool used[MAX];
    memset(used, 0, sizeof used);
    for (int j = i; j < N; j++) {
      if (F[V[j]] < i) break;
      if (!used[V[j]]) {
        LAST = max(LAST, L[V[j]]);
        used[V[j]] = 1;
        if (XOR == -1)
          XOR = V[j];
        else
          XOR ^= V[j];
      }
      if (j == LAST) T[i].push_back({j, XOR});
    }
  }
}
int DP[MAX];
int solve(int pos) {
  if (pos == N) return 0;
  if (DP[pos] != -1) return DP[pos];
  int &ans = DP[pos] = solve(pos + 1);
  for (auto x : T[pos]) {
    ans = max(ans, x.second + solve(x.first + 1));
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  V.resize(N);
  for (auto &x : V) cin >> x;
  pre();
  memset(DP, -1, sizeof DP);
  cout << solve(0) << '\n';
  return 0;
}
