#include <bits/stdc++.h>
using namespace std;
int l[5010];
int r[5010];
int arr[5010];
int dp[5010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", arr + i);
    if (l[arr[i]] == 0) l[arr[i]] = i;
    r[arr[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    int x = arr[i];
    dp[i] = dp[i - 1];
    if (r[x] == i) {
      int st = l[x];
      int res = 0;
      bool vis[5010];
      bool f = true;
      memset(vis, 0, sizeof vis);
      for (int j = i; j >= st; --j) {
        if (!vis[arr[j]]) {
          if (r[arr[j]] > i) {
            f = false;
            break;
          }
          vis[arr[j]] = true;
          st = min(st, l[arr[j]]);
          res ^= arr[j];
        }
      }
      if (f) {
        dp[i] = max(dp[i], dp[st - 1] + res);
      }
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}
