#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
vector<int> pos[MAXN];
int arr[MAXN];
int L[MAXN], R[MAXN];
int dp[MAXN];
int n;
int bcc;
int go(int idx) {
  int &ret = dp[idx];
  if (idx == n + 1) return 0;
  if (ret != -1e9) return ret;
  int value = arr[idx];
  vector<bool> vis(5001, 0);
  ret = 0;
  ret = max(ret, go(idx + 1));
  int l = idx, r = R[value];
  int xors = 0;
  for (int i = idx; i <= n; i++) {
    int value = arr[i];
    if (!vis[value]) {
      xors ^= value;
      vis[value] = 1;
    }
    l = min(l, L[value]);
    r = max(r, R[value]);
    if (l < idx && i > idx) break;
    if (l >= idx && r <= i) {
      ret = max(ret, go(i + 1) + xors);
    }
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i <= 5000; i++) dp[i] = -1e9;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    pos[arr[i]].push_back(i);
  }
  for (int i = 0; i <= 5000; i++) {
    if (pos[i].size()) {
      L[i] = pos[i].front();
      R[i] = pos[i].back();
    }
  }
  cout << go(1);
  return 0;
}
