#include <bits/stdc++.h>
using namespace std;
const int mx = 5005;
int pre[mx], nxt[mx], dp[mx], a[mx];
int vis[mx];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(pre, 0, sizeof(pre));
    memset(nxt, 0, sizeof(nxt));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (pre[a[i]] == 0) {
        pre[a[i]] = nxt[a[i]] = i;
      } else {
        nxt[a[i]] = i;
      }
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
      dp[i] = dp[i - 1];
      int st = i;
      int ans = 0;
      memset(vis, 0, sizeof(vis));
      for (int j = i; j >= 1; j--) {
        if (nxt[a[j]] > i) break;
        st = min(st, pre[a[j]]);
        if (!vis[a[j]]) {
          ans ^= a[j];
          vis[a[j]] = 1;
        }
        if (st >= j) dp[i] = max(dp[i], dp[j - 1] + ans);
      }
    }
    cout << dp[n] << endl;
  }
  return 0;
}
