#include <bits/stdc++.h>
using namespace std;
int main() {
  int c[5005], cnt[5005], a[5005], dp[5005], uniq, total, n, curr;
  dp[0] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    c[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    memset(cnt, 0, sizeof(cnt));
    dp[i] = dp[i - 1];
    curr = 0;
    uniq = 0;
    total = 0;
    for (int j = i; j >= 1; j--) {
      if (!cnt[a[j]]) {
        uniq++;
        curr ^= a[j];
      }
      cnt[a[j]]++;
      if (cnt[a[j]] == c[a[j]]) total++;
      if (total == uniq) dp[i] = max(dp[i], dp[j - 1] + curr);
    }
  }
  cout << dp[n] << endl;
}
