#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e3 + 5;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
int a[5005];
int L[5005], R[5005];
int vis[5005], dp[5005];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (!L[a[i]]) L[a[i]] = i;
    R[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    memset(vis, 0, sizeof(vis));
    int st = i, res = 0;
    for (int j = i; j > 0; j--) {
      if (!vis[a[j]]) {
        if (R[a[j]] > i) break;
        if (st > L[a[j]]) st = L[a[j]];
        vis[a[j]] = 1;
        res ^= a[j];
      }
      if (j <= st) dp[i] = max(dp[i], dp[j - 1] + res);
    }
  }
  cout << dp[n] << endl;
  return 0;
}
