#include <bits/stdc++.h>
using namespace std;
int N;
int A[5000];
int L[5001], R[5001];
int dp[5001];
bool seen[5001];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < (5001); i++) L[i] = 1145141919;
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
    L[A[i]] = min(L[A[i]], i);
    R[A[i]] = i;
  }
  dp[0] = 0;
  for (int i = 0; i < (N); i++) {
    int x = A[i];
    if (L[x] == i) {
      int b = 0;
      for (int i = 0; i < (5001); i++) seen[i] = false;
      bool f = true;
      int right = R[x];
      for (int p = L[x]; p <= right; p++) {
        if (L[A[p]] < L[x]) {
          f = false;
          break;
        }
        right = max(right, R[A[p]]);
        if (!seen[A[p]]) b ^= A[p];
        seen[A[p]] = true;
      }
      if (f) dp[right + 1] = max(dp[right + 1], dp[i] + b);
    }
    dp[i + 1] = max(dp[i], dp[i + 1]);
  }
  cout << dp[N] << "\n";
  return 0;
}
