#include <bits/stdc++.h>
using namespace std;
int arr[5010];
int n;
int awl[5010];
int a5er[5010];
long long dp[5010];
int egaba[5010][5010];
set<int> seet;
long long solve(int idx) {
  if (idx > n) return 0;
  long long &ret = dp[idx];
  if (ret != -1) return ret;
  ret = -1e9;
  ret = max(ret, solve(idx + 1));
  for (int i = idx; i <= n; ++i) {
    if (egaba[idx][i] != -1e9) ret = max(ret, (solve(i + 1) + egaba[idx][i]));
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &arr[i]);
    if (awl[arr[i]] == 0) {
      awl[arr[i]] = i;
      a5er[arr[i]] = i;
    } else
      a5er[arr[i]] = i;
  }
  int cnt = 0;
  bool flag = true;
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    int maxx = 0;
    int x = 0;
    int minn = 1e7;
    for (int j = i; j <= n; ++j) {
      seet.insert(arr[j]);
      if (seet.size() > x) {
        ans ^= arr[j];
        x = seet.size();
      }
      maxx = max(maxx, a5er[arr[j]]);
      minn = min(minn, awl[arr[j]]);
      if (j >= maxx && i <= minn)
        egaba[i][j] = ans;
      else {
        egaba[i][j] = -1e9;
      }
    }
    seet.clear();
  }
  memset(dp, -1, sizeof(dp));
  printf("%d\n", solve(1));
  return 0;
}
