#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int dp[5005][5005];
int dp2[5005][5005];
int arr[5005];
int last1[5005];
int first1[5005];
bool is_in1[5005];
bool is_in2[5005];
int cnt;
int solve(int x, int y) {
  if (dp2[x][y] != -1) return dp2[x][y];
  int ans = dp[x][y];
  cnt++;
  if (x == y - 1 || x == y) return ans;
  int tmp = 0;
  int i = x + 1;
  while (i < y) {
    if (i == first1[arr[i]]) {
      tmp += solve(i, last1[arr[i]]);
      i = last1[arr[i]] + 1;
    } else
      i++;
    cnt++;
  }
  dp2[x][y] = max(ans, tmp);
  return max(ans, tmp);
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    last1[arr[i]] = i;
  }
  for (int i = n - 1; i >= 0; i--) first1[arr[i]] = i;
  for (int i = 0; i < 5005; i++)
    for (int j = 0; j < 5005; j++) dp2[i][j] = -1;
  for (int i = 0; i < n; i++) {
    int t1 = last1[arr[i]];
    for (int j = i + 1; j < t1; j++) {
      t1 = max(t1, last1[arr[j]]);
    }
    last1[arr[i]] = t1;
  }
  for (int i = n - 1; i >= 0; i--) {
    int t1 = first1[arr[i]];
    for (int j = i - 1; j >= t1; j--) {
      t1 = min(t1, first1[arr[j]]);
    }
    first1[arr[i]] = t1;
  }
  for (int i = 0; i < n; i++) {
    int curr = 0;
    for (int j = i; j < n; j++) {
      if (!is_in1[arr[j]]) {
        curr ^= arr[j];
        is_in1[arr[j]] = true;
      }
      dp[i][j] = curr;
    }
    for (int i = 0; i < n; i++) is_in1[arr[i]] = false;
  }
  int ans = dp[0][n - 1];
  int tmp = 0;
  int i = 0;
  while (i < n) {
    if (i == first1[arr[i]]) {
      tmp += solve(i, last1[arr[i]]);
      i = last1[arr[i]] + 1;
    } else
      i++;
    cnt++;
  }
  cout << max(ans, tmp) << "\n";
}
