#include <bits/stdc++.h>
using namespace std;
inline void prep() {
  cin.tie(0);
  cin.sync_with_stdio(0);
}
const int MX = 1e5 + 10;
const int mood = ((int)1e9 + 7);
bool instack[5005];
int res[5005][5005];
int mem[5005];
int main() {
  prep();
  int n;
  cin >> n;
  int a[n], fs[5001], ls[5001];
  memset(fs, 0xff, sizeof fs);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (fs[a[i]] == -1) fs[a[i]] = i;
    ls[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    int to_add = 0;
    int mx_end = -1;
    for (int j = i; j < n; ++j) {
      mx_end = max(ls[a[j]], mx_end);
      if (fs[a[j]] < i) break;
      if (!instack[a[j]]) {
        to_add ^= a[j];
        instack[a[j]] = true;
      }
      if (j == ls[a[j]]) instack[a[j]] = false;
      if (mx_end <= j) {
        res[i][j] ^= to_add;
      }
    }
  }
  int *dp = mem + 1;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j >= 0; --j) {
      dp[i] = max(dp[i], res[j][i] + dp[j - 1]);
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}
