#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> numbers(n);
  vector<int> first(5 * (int)1e3 + 1, -1);
  vector<int> last(5 * (int)1e3 + 1, -1);
  vector<int> xor_sum(n);
  for (int i = 0; i < n; ++i) {
    cin >> numbers[i];
    if (first[numbers[i]] == -1) {
      first[numbers[i]] = i;
      if (i == 0)
        xor_sum[i] = numbers[i];
      else
        xor_sum[i] = numbers[i] ^ xor_sum[i - 1];
    } else {
      xor_sum[i] = xor_sum[i - 1];
    }
    last[numbers[i]] = i;
  }
  vector<pair<int, int>> intervals;
  for (int i = 0; i < n; ++i) {
    int end = last[numbers[i]];
    bool can = true;
    for (int j = i; j <= end; ++j) {
      end = max(end, last[numbers[j]]);
      if (first[numbers[j]] < i) {
        can = false;
        break;
      }
    }
    if (can && i == first[numbers[i]]) intervals.push_back(make_pair(i, end));
  }
  sort(intervals.begin(), intervals.end());
  auto it = unique(intervals.begin(), intervals.end());
  intervals.resize(distance(intervals.begin(), it));
  int k = (int)intervals.size();
  vector<int> a(k);
  for (int i = 0; i < k; ++i) {
    a[i] = xor_sum[intervals[i].second];
    if (intervals[i].first != 0) a[i] ^= xor_sum[intervals[i].first - 1];
  }
  vector<int> dp(n, 0);
  for (int i = 0; i < n; ++i) {
    if (i != 0) dp[i] = dp[i - 1];
    for (int j = 0; j < k; ++j) {
      if (intervals[j].second == i) {
        int cur = a[j];
        if (intervals[j].first != 0) cur += dp[intervals[j].first - 1];
        dp[i] = max(dp[i], cur);
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}
