#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int s[N], dp[N] = {0}, n, first[N], last[N], a[N][N], vis[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long(i) = 0; (i) < (N); (i)++) first[i] = n + 1, last[i] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    first[s[i]] = min(first[s[i]], i);
    last[s[i]] = max(last[s[i]], i);
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    memset(vis, 0, sizeof(vis));
    int st = first[s[i]], x = 0;
    for (int j = i; j > 0; j--) {
      if (!vis[s[j]]) {
        if (last[s[j]] > i) break;
        st = min(st, first[s[j]]);
        x ^= s[j];
        vis[s[j]] = 1;
      }
      if (j <= st) dp[i] = max(dp[i], dp[j - 1] + x);
    }
  }
  cout << dp[n] << endl;
  return 0;
}
