#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 10], hash[5555], freq[5555];
  memset(hash, 0, sizeof(hash));
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    hash[arr[i]]++;
  }
  int dp[5555] = {0};
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    memset(freq, 0, sizeof(freq));
    int valid = 0;
    int xor_sum = 0;
    for (int j = i; j >= 1; --j) {
      if (freq[arr[j]] == 0) {
        valid--;
        xor_sum ^= arr[j];
      }
      ++freq[arr[j]];
      if (freq[arr[j]] == hash[arr[j]]) valid++;
      if (valid == 0) dp[i] = max(dp[i], dp[j - 1] + xor_sum);
    }
  }
  cout << dp[n] << endl;
  return 0;
}
