#include <bits/stdc++.h>
using namespace std;
long long ar[5005], lf[5005], rt[5005], dp[5005];
int main() {
  std::ios::sync_with_stdio(false);
  ;
  long long n;
  std::cin >> n;
  for (long long i = 1; i <= n; i++) {
    std::cin >> ar[i];
    rt[ar[i]] = i;
  }
  for (long long i = n; i >= 1; i--) {
    lf[ar[i]] = i;
  }
  long long ans = -1;
  for (long long i = 1; i <= n; i++) {
    long long f[5005], xl[5005], xr[5005];
    bool mark[5005];
    memset(xr, 0, sizeof(xr));
    memset(mark, false, sizeof(mark));
    memset(f, 10000, sizeof(f));
    for (long long j = i; j >= 1; j--) {
      f[j] = min(f[j + 1], lf[ar[j]]);
    }
    for (long long j = i; j >= 1; j--) {
      xl[j] = max(xl[j + 1], rt[ar[j]]);
    }
    for (long long j = i; j >= 1; j--) {
      if (!mark[ar[j]])
        xr[j] = xr[j + 1] ^ ar[j];
      else {
        xr[j] = xr[j + 1];
      }
      mark[ar[j]] = true;
    }
    for (long long j = 1; j <= i; j++) {
      if (f[j] >= j && xl[j] <= i) {
        dp[i] = max(xr[j] + dp[j - 1], dp[i - 1]);
      }
      dp[i] = max(dp[i], dp[i - 1]);
    }
    ans = max(dp[i], ans);
  }
  std::cout << ans << endl;
  return 0;
}
