#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const int maxm = 10005;
const int mod = 1000000009;
int n, m;
int num[maxn];
int ll[maxn], rr[maxn];
int dp[maxn][maxn];
bool vis[maxn];
bool fen[maxn];
int val[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
  }
  for (int i = 1; i <= n; i++) {
    int cc = num[i];
    if (ll[cc] == 0) ll[cc] = i;
  }
  for (int i = n; i > 0; i--) {
    int cc = num[i];
    if (rr[cc] == 0) rr[cc] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (ll[num[i]] == i) {
      fen[i] = 1;
      memset(vis, 0, sizeof(vis));
      for (int j = i; j <= rr[num[i]]; j++) {
        if (!vis[num[j]]) {
          vis[num[j]] = 1;
          val[i] ^= num[j];
        }
        if (ll[num[j]] < i) {
          fen[i] = 0;
          break;
        }
        if (rr[num[j]] > rr[num[i]]) rr[num[i]] = rr[num[j]];
      }
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i + k - 1 <= n; i++) {
      int j = i + k - 1;
      if (fen[i] && rr[num[i]] <= j) {
        dp[i][j] = max(val[i] + dp[rr[num[i]] + 1][j], dp[i + 1][j]);
      } else {
        dp[i][j] = max(dp[i][j], dp[i + 1][j]);
      }
    }
  }
  printf("%d\n", dp[1][n]);
  return 0;
}
