#include <bits/stdc++.h>
inline long long sbt(long long x) { return __builtin_popcount(x); }
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long n;
long long dp[5013], l[5013], r[5013], dp1[5013][5013], vis[5013], a[5013];
long long f(long long i) {
  if (i == (n + 1)) return 0;
  if (dp[i] != -1) return dp[i];
  long long res = 0, ans;
  res = f(i + 1);
  ans = res;
  long long fl = 1;
  long long shuru = l[a[i]];
  long long khatam = r[a[i]];
  long long mini_f = shuru, maxi_l = khatam;
  for (long long j = shuru; j <= khatam; j++) {
    mini_f = min(mini_f, l[a[j]]);
    maxi_l = max(maxi_l, r[a[j]]);
  }
  if (mini_f < i) {
    return dp[i] = ans;
  }
  res = dp1[mini_f][maxi_l] + f(maxi_l + 1);
  return dp[i] = max(res, ans);
}
int32_t main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n;
  memset(l, -1, sizeof l);
  memset(r, -1, sizeof r);
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (l[a[i]] == -1) l[a[i]] = i;
    r[a[i]] = i;
  }
  memset(dp, -1, sizeof dp);
  memset(dp1, 0, sizeof dp1);
  for (long long i = 1; i <= n; i++) {
    memset(vis, 0, sizeof vis);
    for (long long j = i; j <= n; j++) {
      if (!vis[a[j]]) {
        dp1[i][j] = dp1[i][j - 1] ^ a[j];
      } else {
        dp1[i][j] = dp1[i][j - 1];
      }
      vis[a[j]] = 1;
    }
  }
  cout << f(0);
  return 0;
}
