#include <bits/stdc++.h>
using namespace std;
int xx[5005][5005];
int last[5005][2];
int arr[5005];
int dp[5005], n;
int fnc(int num) {
  if (num >= n) return 0;
  int ans, ans2, ans3;
  if (dp[num] != -1) return dp[num];
  if (last[arr[num]][0] < num)
    ans = fnc(num + 1);
  else {
    ans2 = fnc(last[arr[num]][1] + 1);
    ans3 = fnc(num + 1);
    ans = max(ans2 ^ xx[num][last[arr[num]][1]],
              ans2 + xx[num][last[arr[num]][1]]);
    ans = max(ans, ans3);
  }
  dp[num] = ans;
  return ans;
}
int main() {
  int i, ans, j;
  cin >> n;
  memset(last, -1, sizeof(last));
  memset(dp, -1, sizeof(dp));
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    if (last[arr[i]][0] == -1) last[arr[i]][0] = i;
    last[arr[i]][1] = i;
  }
  int visited[5005];
  int maxi, mini;
  for (i = 0; i < n; i++) {
    maxi = -1;
    mini = last[arr[last[arr[i]][1]]][0];
    for (j = last[arr[i]][1]; j >= (last[arr[i]][0]); j--) {
      maxi = max(maxi, last[arr[j]][1]);
      mini = min(mini, last[arr[j]][0]);
    }
    last[arr[i]][1] = maxi;
    last[arr[i]][0] = mini;
  }
  for (i = 0; i < n; i++) {
    ans = 0;
    memset(visited, 0, sizeof(visited));
    for (j = i; j < n; j++) {
      if (visited[arr[j]] == 0) {
        ans = ans ^ arr[j];
        visited[arr[j]] = 1;
      }
      xx[i][j] = ans;
    }
  }
  ans = fnc(0);
  cout << ans << endl;
}
