#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
};
template <class A, class B>
ostream &operator<<(ostream &os, pair<A, B> p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, rge<T> d) {
  os << "[";
  for (auto it = d.b; it != d.e; it++) os << (it == d.b ? "" : ", ") << *it;
  return os << "]";
}
const int N = 5005;
int code[N];
int lo[N], hi[N];
bool add[N];
int dp[N];
int n;
template <class T>
void umax(T &a, T b) {
  a = max(a, b);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
  cin >> n;
  for (int i = (1); i <= ((n)); i += (+1)) {
    cin >> code[i];
    if (!lo[code[i]]) {
      lo[code[i]] = hi[code[i]] = i;
    } else {
      hi[code[i]] = i;
    }
  }
  dp[0] = 0;
  for (int r = (1); r <= ((n)); r += (+1)) {
    dp[r] = dp[r - 1];
    fill_n(add, N, false);
    int comfort = 0;
    pair<int, int> trip = {r, r};
    for (int l = (r); l >= (1); l += (-1)) {
      if (!add[code[l]]) {
        add[code[l]] = true;
        comfort ^= code[l];
      }
      trip.first = min(trip.first, lo[code[l]]);
      trip.second = max(trip.second, hi[code[l]]);
      if (trip > pair<int, int>{l, r}) {
        break;
      }
      if (trip.first == l) {
        umax(dp[r], dp[l - 1] + comfort);
      }
    }
  }
  cout << dp[n] << '\n';
  return 0;
}
