#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10;
int a[N], dp[N], f[N], l[N];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (f[a[i]] == 0) {
      f[a[i]] = i;
    }
    l[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    int max1 = 0, min1 = N, cur = 0, j = i;
    bool pr = 0;
    map<int, int> m;
    map<int, int>::iterator it;
    while (j > 0 && !pr) {
      max1 = max(max1, l[a[j]]);
      min1 = min(min1, f[a[j]]);
      it = m.find(a[j]);
      if (it == m.end()) {
        cur = cur ^ a[j];
        m.insert(make_pair(a[j], 1));
      }
      if (i >= max1 && j <= min1) {
        pr = 1;
        dp[i] = dp[j - 1] + cur;
      }
      j--;
    }
    if (!pr) {
      dp[i] = dp[i - 1];
    } else {
      dp[i] = max(dp[i], dp[i - 1]);
    }
  }
  int max1 = 0;
  for (int i = 1; i <= n; i++) {
    max1 = max(max1, dp[i]);
  }
  cout << max1 << "\n";
  return 0;
}
