#include <bits/stdc++.h>
using namespace std;
long long a[5005], l[5005], r[5005], dp[5005][5005], n, f[5005];
bool mark[5005][5005], used[5005];
int main() {
  scanf("%lld", &n);
  for (int i = 0; i <= 5000; i++) {
    l[i] = 10000;
    r[i] = -1;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    l[a[i]] = min(l[a[i]], (long long)(i));
    r[a[i]] = max(r[a[i]], (long long)(i));
  }
  for (int i = 0; i <= 5000; i++) {
    if (r[i] != -1 && l[i] != 10000) {
      long long isum = 0, left = 10000, right = -1;
      for (int j = l[i]; j <= r[i]; j++) {
        left = min(left, l[a[j]]);
        right = max(right, r[a[j]]);
      }
      l[i] = left;
      r[i] = right;
      memset(used, 0, sizeof(used));
      for (int j = l[i]; j <= r[i]; j++) {
        if (used[a[j]] == 0) {
          isum ^= a[j];
        }
        used[a[j]] = 1;
      }
      for (int j = l[i]; j <= r[i]; j++) used[a[j]] = 0;
      dp[l[i]][r[i]] = isum;
    }
  }
  f[0] = 0;
  for (int i = 1; i <= n; i++) f[i] = 0;
  for (int i = 1; i <= n; i++) {
    f[i] = max(f[i], f[i - 1]);
    if (i == r[a[i]]) {
      f[i] = max(f[i], f[l[a[i]] - 1] + dp[l[a[i]]][r[a[i]]]);
    }
  }
  cout << f[n];
}
