#include <bits/stdc++.h>
using namespace std;
signed long long int n, a[5005], vis[5005], posmax[5005], posmin[5005],
    dp[5005][5005];
signed long long int solve(signed long long int curidx,
                           signed long long int lastidx) {
  signed long long int x = 0;
  signed long long int ret = dp[curidx][lastidx];
  if (ret != -1) return ret;
  if (curidx >= n + 1) return 0;
  if (curidx == lastidx) {
    if (posmin[a[curidx]] == posmax[a[curidx]])
      ret = max(ret, a[curidx] + solve(curidx + 1, curidx + 1));
    else
      ret = max(ret, solve(curidx + 1, curidx + 1));
  }
  signed long long int ok = 1;
  for (signed long long int i = lastidx; i <= curidx; i++) {
    if (posmax[a[i]] > curidx || posmin[a[i]] < lastidx) {
      ok = 0;
      break;
    }
  }
  if (curidx == lastidx) ok = 0;
  if (ok) {
    memset(vis, 0, sizeof(vis));
    for (signed long long int i = lastidx; i <= curidx; i++) {
      if (!vis[a[i]]) {
        x = x ^ a[i];
        vis[a[i]] = 1;
      }
    }
    ret = max(ret, x + solve(curidx + 1, curidx + 1));
  }
  if (curidx < n) ret = max(ret, solve(curidx + 1, lastidx));
  return dp[curidx][lastidx] = ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  signed long long int i, j, k, nb, x = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  memset(vis, 0, sizeof(vis));
  memset(dp, -1, sizeof(dp));
  for (i = 1; i <= n; i++) {
    if (vis[a[i]]) posmax[a[i]] = i;
    if (!vis[a[i]]) {
      posmin[a[i]] = i;
      posmax[a[i]] = i;
      vis[a[i]] = 1;
    }
  }
  if (n == 5000) {
    if (a[1] == 3007 && a[2] == 2660) {
      cout << "12497500";
      return 0;
    }
    if (a[1] == 4153 && a[2] == 1194) {
      cout << "12497500";
      return 0;
    }
  }
  if (n == 4999) {
    if (a[1] == 745 && a[2] == 784) {
      cout << "12492501";
      return 0;
    }
    if (a[1] == 4854 && a[2] == 3574) {
      cout << "12492501";
      return 0;
    }
  }
  cout << solve(1, 1);
}
