#include <bits/stdc++.h>
using namespace std;
const int MaxN = 5000;
int w[MaxN + 5], a[MaxN + 5], t[MaxN + 5], pus[MaxN + 5], ans[MaxN + 5];
int dp[MaxN + 5], tt, ww;
int So(int sum, int i) {
  int pp = tt;
  for (int j = tt; j <= ww; j++) {
    if (!pus[a[j]]) {
      tt = min(tt, t[a[j]]);
      ww = max(ww, w[a[j]]);
      if (ww > i) break;
      sum ^= a[j];
      pus[a[j]] = 1;
    }
  }
  if (ww <= i && tt != pp) sum = So(sum, i);
  return sum;
}
int main() {
  int n, cnt, ans, sum, aa, bb, Max;
  while (~scanf("%d", &n)) {
    ans = 0;
    cnt = 0;
    Max = 0;
    for (int i = 0; i <= MaxN; i++) {
      t[i] = 5001;
      w[i] = 0;
      dp[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      w[a[i]] = max(w[a[i]], i);
      t[a[i]] = min(t[a[i]], i);
    }
    for (int i = 1; i <= n; i++) {
      dp[i] = Max;
      if (w[a[i]] != i) continue;
      sum = 0;
      ww = w[a[i]];
      tt = t[a[i]];
      for (int j = 0; j <= MaxN; j++) pus[j] = 0;
      sum = So(sum, i);
      if (ww > i) continue;
      dp[i] = max(dp[i], dp[tt - 1] + sum);
      Max = max(dp[i], Max);
    }
    printf("%d\n", Max);
  }
  return 0;
}
