#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int n;
int a[5005];
int fi[5005], la[5005];
int dp[5005];
bool vis[5005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (!fi[a[i]]) fi[a[i]] = i;
    la[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    memset(vis, 0, sizeof(vis));
    int st = i;
    int res = 0;
    for (int j = i; j >= 1; j--) {
      if (!vis[a[j]]) {
        if (la[a[j]] > i) break;
        if (fi[a[j]] < st) st = fi[a[j]];
        res ^= a[j];
        vis[a[j]] = 1;
      }
      if (j <= st) dp[i] = max(dp[i], dp[j - 1] + res);
    }
  }
  cout << dp[n] << endl;
}
