#include <bits/stdc++.h>
using namespace std;
long int n;
long int first[5005];
long int last[5005];
long int sum;
long int dp[5005];
long int m[5005];
long int a[5005];
long int NN;
vector<pair<long int, long int> > A[5005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    last[a[i]] = i;
    if (!first[a[i]]) first[a[i]] = i;
  }
  for (long int i = 0; i < n; i++) {
  }
  int x;
  for (long int i = 1; i <= n; i++) {
    sum = 0;
    x = 0;
    for (long int j = 1; j <= n; j++) m[a[j]] = 0;
    for (long int j = i; j <= n; j++) {
      if (!m[a[j]]) {
        m[a[j]] = 1;
        x += 2;
        sum ^= a[j];
      }
      if (last[a[j]] == j) x--;
      if (first[a[j]] == j) x--;
      if (!x) A[j].push_back(make_pair(i, sum));
    }
  }
  dp[0] = 0;
  for (long int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    for (long int j = 0; j < A[i].size(); j++) {
      dp[i] = max(dp[i], dp[A[i][j].first - 1] + A[i][j].second);
    }
  }
  cout << dp[n];
  return 0;
}
