#include <bits/stdc++.h>
using namespace std;
int l[5050];
int r[5050];
int dp[5050];
int a[5050];
int xo[5050][5050];
int minn;
bool check(int low, int high) {
  for (int i = low; i <= high; i++) {
    if (r[a[i]] > high) {
      return false;
    }
    minn = min(minn, l[a[i]]);
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) xo[i][i] = a[i];
  bool vis[5050];
  for (int i = 1; i <= n; i++) {
    memset(vis, false, sizeof(vis));
    vis[a[i]] = true;
    for (int j = i + 1; j <= n; j++) {
      if (vis[a[j]] == false)
        xo[i][j] = xo[i][j - 1] ^ a[j];
      else
        xo[i][j] = xo[i][j - 1];
      vis[a[j]] = true;
    }
  }
  memset(vis, false, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (vis[a[i]] == false) {
      vis[a[i]] = true;
      l[a[i]] = i;
    }
    r[a[i]] = i;
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    int low = l[a[i]];
    minn = 0x3f3f3f3f;
    if (check(low, i) == false)
      dp[i] = dp[i - 1];
    else {
      dp[i] = max(dp[i - 1], dp[minn - 1] + xo[minn][i]);
    }
  }
  cout << dp[n] << endl;
}
