#include <bits/stdc++.h>
using namespace std;
const int M = 5e3 + 7;
long long dp[M];
int a[M], st[M], ed[M];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) ed[a[i]] = i;
  for (int i = n; i >= 0; i--) st[a[i]] = i;
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (ed[a[i]] != i)
      dp[i] = max(dp[i - 1], dp[i]);
    else {
      set<int> sx;
      int mn = st[a[i]];
      bool isValid = true;
      for (int j = i; j >= mn; j--) {
        if (ed[a[j]] > ed[a[i]]) {
          isValid = false;
          break;
        }
        mn = min(mn, st[a[j]]);
        sx.insert(a[j]);
      }
      if (isValid) {
        int s = 0;
        set<int>::iterator it;
        for (it = sx.begin(); it != sx.end(); it++) s ^= *it;
        dp[i] = max(dp[i - 1], dp[mn - 1] + s);
      } else
        dp[i] = max(dp[i - 1], dp[i]);
    }
  }
  cout << dp[n] << "\n";
  return 0;
}
