#include <bits/stdc++.h>
using namespace std;
int n;
int a[5050];
int dp[5050];
int l[5050];
int r[5050];
unordered_set<int> was;
inline bool here(int val) { return was.find(val) != was.end(); }
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  fill_n(l, 5050, 100500);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    l[a[i]] = min(l[a[i]], i);
    r[a[i]] = max(r[a[i]], i);
  }
  dp[0] = (l[a[0]] == 0 && r[a[0]] == 0) ? a[0] : 0;
  for (int i = 1; i < n; ++i) {
    was.clear();
    int ksor = 0;
    int lb = 100500;
    int rb = 0;
    dp[i] = dp[i - 1];
    for (int j = i; j >= 0; j--) {
      lb = min(lb, l[a[j]]);
      rb = max(rb, r[a[j]]);
      if (rb > i) break;
      if (!here(a[j])) {
        was.insert(a[j]);
        ksor ^= a[j];
      }
      if (lb >= j && rb <= i) {
        if (j > 0)
          dp[i] = max(dp[i], dp[j - 1] + ksor);
        else
          dp[i] = max(dp[i], ksor);
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}
