#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int M = 5e3 + 5;
int n, a[M], dp[M], l[M], r[M];
bool us[M];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    l[a[i]] = -1;
    r[a[i]] = i;
  }
  for (int i = 0; i < n; ++i)
    if (l[a[i]] == -1) l[a[i]] = i;
  for (int i = 0; i < n; ++i)
    if (l[a[i]] == i) {
      int c = i, d = i;
      for (int i = 0; i < n; ++i) us[a[i]] = 0;
      vector<int> q;
      q.push_back(a[i]);
      us[a[i]] = 1;
      int ans = 0;
      while (q.size()) {
        int x = q.back();
        ans ^= x;
        q.pop_back();
        for (int j = l[x]; j < c; ++j)
          if (!us[a[j]]) us[a[j]] = 1, q.push_back(a[j]);
        for (int j = d + 1; j <= r[x]; ++j)
          if (!us[a[j]]) us[a[j]] = 1, q.push_back(a[j]);
        c = min(c, l[x]);
        d = max(d, r[x]);
      }
      for (int j = d; j < n; ++j)
        dp[j] = max(dp[j], (c == 0 ? 0 : dp[c - 1]) + ans);
    }
  cout << dp[n - 1];
}
