#include <bits/stdc++.h>
using namespace std;
const int M = 0;
const int N = 5010;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
struct Se {
  int l, r, x;
  Se(int l = INF, int r = -1, int x = 0) : l(l), r(r) {}
  bool operator<(const Se& a) const { return l == a.l ? r < a.r : l < a.l; }
} se[N];
int n, num[N], X[N], dp[N] = {0};
bool vis[N] = {0};
vector<Se> ve;
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &num[i]);
    int tmp = num[i];
    if (!vis[tmp]) {
      vis[tmp] = true;
      se[tmp].l = i;
    }
    se[tmp].r = i;
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < n; ++i)
    if (!vis[num[i]]) {
      vis[num[i]] = true;
      Se& tmp = se[num[i]];
      bool inc[N] = {0};
      int sum = 0, l = INF;
      for (int j = tmp.l; j <= tmp.r; ++j)
        if (!inc[num[j]]) {
          inc[num[j]] = true;
          sum ^= num[j];
          tmp.r = max(tmp.r, se[num[j]].r);
          l = min(l, se[num[j]].l);
        }
      tmp.x = sum;
      if (l >= tmp.l) ve.push_back(tmp);
    }
  int m = ve.size(), ans = 0;
  sort(ve.begin(), ve.end());
  for (int i = 0; i < m; ++i) {
    dp[i] = ve[i].x;
    for (int j = 0; j < i; ++j)
      if (ve[j].r < ve[i].l) dp[i] = max(dp[i], dp[j] + ve[i].x);
  }
  for (int i = 0; i < m; ++i) ans = max(ans, dp[i]);
  printf("%d\n", ans);
  return 0;
}
