#include <bits/stdc++.h>
typedef struct Segment {
  int start;
  int last;
  int Xor;
} segment;
using namespace std;
vector<segment> V;
int score(segment s) {
  if (s.last == s.start)
    return s.Xor;
  else {
    int value = 0;
    for (int i = s.start + 1; i < s.last;) {
      if (V[i].start == -1)
        i++;
      else {
        value += score(V[i]);
        i = V[i].last + 1;
      }
    }
    return max(value, s.Xor);
  }
}
int cities_final[5010];
int cities_first[5010];
int cities[5010];
int main() {
  int n;
  scanf("%d", &n);
  int people[n];
  int cumulativeXOR[n + 1];
  cumulativeXOR[0] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &people[i]);
    if (!cities[people[i]])
      cumulativeXOR[i + 1] = cumulativeXOR[i] ^ people[i];
    else
      cumulativeXOR[i + 1] = cumulativeXOR[i];
    if (!cities[people[i]]) cities_first[people[i]] = i;
    cities[people[i]] = 1;
    cities_final[people[i]] = i;
  }
  int start;
  int last;
  int Xor;
  for (int i = 0; i < n; i++) {
    start = i;
    last = i;
    int flag = 0;
    if (cities[people[i]]) {
      for (int j = i; j <= last; j++) {
        if (cities_first[people[j]] < start) {
          flag = 1;
        }
        if (cities_final[people[j]] > last) last = cities_final[people[j]];
      }
      Xor = cumulativeXOR[last + 1] ^ cumulativeXOR[start];
      segment s;
      s.start = start;
      s.last = last;
      s.Xor = Xor;
      if (flag) s.start = -1;
      cities[people[i]] = 0;
      V.push_back(s);
    } else {
      segment s;
      s.start = -1;
      V.push_back(s);
    }
  }
  int ans = 0;
  for (int i = 0; i < n;) {
    ans += score(V[i]);
    i = V[i].last + 1;
  }
  printf("%d", ans);
}
