#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a(5005);
int occ[5005][2];
int dp[5005];
int vis[5005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (!occ[a[i]][0]) occ[a[i]][0] = i;
    occ[a[i]][1] = i;
  }
  for (int i = 1; i <= n; ++i) {
    int cur = 0;
    int fst = i;
    memset(vis, 0, sizeof(vis));
    dp[i] = dp[i - 1];
    for (int j = i; j >= 1; --j) {
      if (vis[a[j]] == 0) {
        if (occ[a[j]][1] > i) break;
        if (occ[a[j]][0] < fst) fst = occ[a[j]][0];
        cur ^= a[j];
        vis[a[j]] = 1;
      }
      if (j <= fst) {
        dp[i] = max(dp[i], dp[j - 1] + cur);
      }
    }
  }
  cout << dp[n] << endl;
}
