#include <bits/stdc++.h>
using namespace std;
int firstAppear[100000];
int lastAppear[100000];
int arr[100000];
int Xors[5005][5005];
map<int, bool> used;
int DP[100000];
int n;
int Best = 0;
int solve(int index) {
  if (index >= n + 1) return 0;
  if (DP[index] != -1) return DP[index];
  int sum = solve(index + 1);
  int lastFound = lastAppear[arr[index]];
  for (int i = index; i <= n; i++) {
    if (firstAppear[arr[i]] < index) break;
    lastFound = max(lastFound, lastAppear[arr[i]]);
    if (lastFound == i)
      sum = max(Xors[index][i] + solve(lastAppear[arr[i]] + 1), sum);
  }
  return DP[index] = sum;
}
int main() {
  memset(DP, -1, sizeof DP);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    if (firstAppear[arr[i]] == 0)
      firstAppear[arr[i]] = i, lastAppear[arr[i]] = i;
    else
      lastAppear[arr[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    int XX = 0;
    bool found[5005];
    memset(found, 0, sizeof found);
    for (int j = i; j <= n; j++) {
      if (!found[arr[j]]) {
        XX ^= arr[j];
        found[arr[j]] = true;
      }
      Xors[i][j] = XX;
    }
  }
  cout << solve(1);
  return 0;
}
