#include <bits/stdc++.h>
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
int t[5007];
int dp[5007];
int first[5007];
int last[5007];
bool b[5007];
int32_t main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
    if (first[t[i]] == 0) first[t[i]] = i;
    last[t[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    int x = 0, F = i, L = i;
    for (int j = i; j >= 1; --j) {
      if (b[t[j]] == 0) {
        x ^= t[j];
        b[t[j]] = 1;
      }
      L = max(L, last[t[j]]);
      F = min(F, first[t[j]]);
      if (L <= i && F >= j) dp[i] = max(dp[i], x + dp[j - 1]);
    }
    dp[i] = max(dp[i], dp[i - 1]);
    for (int j = 0; j <= 5000; ++j) b[j] = 0;
  }
  printf("%d", dp[n]);
}
