#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), l(5050), r(5050);
  vector<long long> dp(n + 1, 0);
  for (long long i = 0; i < (n); i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < (n); i++) r[a[i]] = i;
  for (long long i = (n - 1); i >= (0); i--) l[a[i]] = i;
  for (long long i = 0; i < (n); i++) {
    bool possible = 1;
    int left = l[a[i]];
    long long x = 0;
    for (long long j = (i); j >= (left); j--) {
      if (r[a[j]] > i) {
        dp[i + 1] = dp[i];
        possible = 0;
        break;
      }
      left = min(left, l[a[j]]);
      if (j == l[a[j]]) x ^= a[j];
    }
    if (possible) dp[i + 1] = max(dp[i], x + dp[left]);
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
}
