#include <bits/stdc++.h>
using namespace std;
int n, dp[5005], lst[5005], a[5005], fir[5005], vis[5005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]), lst[a[i]] = i,
                        fir[a[i]] = (fir[a[i]] == 0 ? i : fir[a[i]]);
  for (int i = 1; i <= n; ++i) {
    dp[i] = dp[i - 1];
    memset(vis, 0, sizeof(vis));
    int tmp = 0, id = i, rid = 1;
    for (int j = i; j; --j) {
      if (!vis[a[j]])
        vis[a[j]] = 1, tmp ^= a[j], id = min(id, fir[a[j]]),
        rid = max(rid, lst[a[j]]);
      if (id >= j && rid <= i) {
        dp[i] = max(dp[i], dp[j - 1] + tmp);
      }
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}
