#include <bits/stdc++.h>
const long long N = 5001;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[N];
  for (int i = 1; i <= n; i++) cin >> a[i];
  int fir[N] = {0}, las[N] = {0};
  for (int i = 1; i <= n; i++) las[a[i]] = i;
  for (int i = n; i >= 1; i--) fir[a[i]] = i;
  int vis[N];
  int dp[N] = {0};
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    int sum = 0;
    memset(vis, 0, sizeof(vis));
    int st = fir[a[i]];
    for (int j = i; j >= 1; j--) {
      if (vis[a[j]] == 0) {
        if (las[a[j]] > i) break;
        st = min(st, fir[a[j]]);
        sum ^= a[j];
        vis[a[j]] = 1;
      }
      if (j == st) dp[i] = max(dp[i], dp[j - 1] + sum);
    }
  }
  cout << dp[n] << endl;
  return 0;
}
