#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int num[N];
int dp[N];
int vis[N];
int vis2[N];
int vis3[N];
int _end[N];
int start[N];
int main() {
  int n, m, l, r, d;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
    if (!vis2[num[i]]) vis2[num[i]] = i;
    vis3[num[i]] = i;
  }
  for (int i = 0; i <= 5000; i++) _end[vis3[i]] = 1;
  for (int i = 0; i <= 5000; i++) start[vis2[i]] = 1;
  for (int i = 1; i <= n; i++) {
    int minx = 0;
    if (_end[i]) {
      int ans = 0;
      memset(vis, 0, sizeof(vis));
      minx = vis2[num[i]];
      for (int j = i; j >= minx; j--) {
        if (_end[j]) {
          vis[num[j]] = 1;
          minx = min(minx, vis2[num[j]]);
        }
        if (!vis[num[j]]) break;
        if (start[j]) ans ^= num[j];
      }
      dp[i] = ans;
    }
    int ans = 0;
    for (int j = 1; j < minx; j++) {
      ans = max(ans, dp[j]);
    }
    dp[i] += ans;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}
