#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 10;
const int maxm = 2e5 + 10;
const long long mod = 1e9 + 7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
int n, a[maxn];
bool vis[maxn];
int dp[maxn];
struct Node {
  int l, r;
} node[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (node[a[i]].l == 0) node[a[i]].l = i;
    node[a[i]].r = i;
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    memset(vis, 0, sizeof(vis));
    int st = node[a[i]].l;
    int res = 0;
    for (int j = i; j >= 1; j--) {
      if (!vis[a[j]]) {
        if (node[a[j]].r > i) break;
        st = min(st, node[a[j]].l);
        res ^= a[j];
        vis[a[j]] = 1;
      }
      if (j <= st) dp[i] = max(dp[i], dp[j - 1] + res);
    }
  }
  cout << dp[n];
  return ~~(0 - 0);
}
