#include <bits/stdc++.h>
using namespace std;
int dp[5005];
int check[5005];
int a[5005];
int s[5005];
int e[5005];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (!s[a[i]]) s[a[i]] = i;
    e[a[i]] = i;
  }
  for (int i = n; i >= 1; i--) {
    dp[i] = dp[i + 1];
    if (s[a[i]] == i) {
      memset(check, 0, sizeof(check));
      int sum = a[i];
      int _end = e[a[i]];
      int ok = 0;
      check[a[i]] = 1;
      for (int j = i + 1; j <= _end; j++) {
        if (check[a[j]] == 0) {
          check[a[j]] = 1;
          if (s[a[j]] != j) {
            ok = 1;
            break;
          } else {
            sum ^= a[j];
            _end = max(_end, e[a[j]]);
          }
        }
      }
      if (ok == 0) dp[i] = max(dp[i], dp[_end + 1] + sum);
    }
  }
  cout << dp[1];
}
