#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
int n, ori[5001], v[5001], is[5001], ls[5001], ed[5001], st[5001], dp[5001],
    comf[5001];
bool cant[5001];
int calc(int u) {
  if (u == n) return 0;
  int &ret = dp[u];
  if (ret != -1) return ret;
  ret = calc(u + 1);
  if (!cant[v[u]] && st[v[u]] == u)
    ret = max(ret, comf[v[u]] + calc(ed[v[u]] + 1));
  return ret;
}
int main() {
  memset(is, -1, sizeof(is));
  memset(st, -1, sizeof(st));
  cin >> n;
  for (int x, i = 0; i < n; ++i) {
    scanf("%d", &x);
    v[i] = x;
    if (st[x] == -1) st[x] = i;
    ls[x] = i;
  }
  for (int i = 0; i < n; ++i) {
    if (st[v[i]] != i) continue;
    int cur = ls[v[i]];
    for (int j = i; j < cur; ++j) cur = max(cur, ls[v[j]]);
    ed[v[i]] = cur;
  }
  for (int i = 0; i < 5001; ++i) {
    if (st[i] == -1) continue;
    bool vis[5001] = {};
    for (int j = st[i]; j <= ed[i]; ++j) {
      if (!vis[v[j]]) {
        if (st[v[j]] != j) cant[i] = true;
        vis[v[j]] = true;
        comf[i] ^= v[j];
      }
    }
  }
  memset(dp, -1, sizeof(dp));
  cout << calc(0) << endl;
}
