#include <bits/stdc++.h>
using namespace std;
const int Nmax = 5000;
int a[Nmax], f[Nmax + 1], l[Nmax + 1], luat[Nmax + 1];
int dp[Nmax + 1];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= Nmax; i++) {
    f[i] = -1;
    l[i] = -1;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (f[a[i]] == -1) {
      f[a[i]] = i;
    }
    l[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    if (l[a[i]] != i) {
      dp[i + 1] = dp[i];
      continue;
    }
    for (int j = 0; j <= Nmax; j++) {
      luat[j] = 0;
    }
    int st = f[a[i]], dr = l[a[i]];
    int x = 0;
    for (int j = l[a[i]]; j >= f[a[i]]; j--) {
      if (luat[a[j]] == 0) {
        x ^= a[j];
      }
      luat[a[j]] = 1;
      st = min(st, f[a[j]]);
      dr = max(dr, l[a[j]]);
    }
    for (int j = f[a[i]] - 1; j >= st; j--) {
      if (luat[a[j]] == 0) {
        x ^= a[j];
      }
      luat[a[j]] = 1;
    }
    if (l[a[i]] >= dr) {
      dp[i + 1] = max(max(dp[i + 1], dp[i]), dp[st] + x);
    } else {
      dp[i + 1] = dp[i];
    }
  }
  cout << dp[n];
  return 0;
}
