#include <bits/stdc++.h>
using namespace std;
int dp[5005], a[5005], sum[5005], all[5005];
int main() {
  int i, j, n, m, res, have, now;
  scanf("%d", &n);
  memset(all, 0, sizeof(all));
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    all[a[i]]++;
  }
  for (i = 0; i < n; i++) {
    memset(sum, 0, sizeof(sum));
    dp[i] = 0;
    res = 0;
    have = 0;
    now = 0;
    if (i) dp[i] = dp[i - 1];
    for (j = i; j >= 0; j--) {
      if (sum[a[j]] == 0) {
        res ^= a[j];
        have++;
      }
      sum[a[j]]++;
      if (sum[a[j]] == all[a[j]]) {
        now++;
      }
      if (now == have) {
        dp[i] = max(dp[i], dp[j - 1] + res);
      }
    }
  }
  cout << dp[n - 1] << endl;
}
