#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 7;
const int inf = 1e9;
int n;
int num[MAXN], dp[MAXN];
int first_pos[MAXN], last_pos[MAXN];
bool vis[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &num[i]);
    if (!first_pos[num[i]]) first_pos[num[i]] = i;
    last_pos[num[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    dp[i] = dp[i - 1];
    memset(vis, 0, sizeof(vis));
    int st = first_pos[num[i]];
    int res = 0;
    for (int j = i; j >= 1; --j) {
      if (!vis[num[j]]) {
        if (last_pos[num[j]] > i) break;
        st = min(st, first_pos[num[j]]);
        res ^= num[j];
        vis[num[j]] = 1;
      }
      if (j == st) {
        dp[i] = max(dp[i], dp[j - 1] + res);
        break;
      }
    }
  }
  printf("%d\n", dp[n]);
}
