#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
int a[5005], mi[5005], ma[5005], dp[5005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (!mi[a[i]]) mi[a[i]] = i;
  }
  for (int i = n; i >= 1; i--) {
    if (!ma[a[i]]) ma[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    bool vis[5005] = {0};
    int now = 5005, sum = 0;
    dp[i] = dp[i - 1];
    for (int j = i; j >= 1; j--) {
      if (ma[a[j]] > i) break;
      now = min(now, mi[a[j]]);
      if (!vis[a[j]]) vis[a[j]] = 1, sum ^= a[j];
      if (now == j) dp[i] = max(dp[i], dp[j - 1] + sum);
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}
