#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using UI = unsigned int;
using UC = unsigned char;
using VI = std::vector<int>;
using SI = std::set<int>;
using PI = std::pair<int, int>;
using PL = std::pair<LL, LL>;
constexpr LL MOD = 1000000009;
constexpr double EXP = 2.7182818284590452;
constexpr double Pi = 3.1415926535;
constexpr long double EPS = 1e-4;
constexpr int INF = 1000 * 1000 * 1001;
constexpr long long INFL = (LL)INF * (LL)INF;
inline LL gcd(LL a, LL b) {
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
inline LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }
LL extgcd(LL a, LL b, LL& x, LL& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  LL x11, y11;
  LL d = extgcd(b % a, a, x11, y11);
  x = y11 - (b / a) * x11;
  y = x11;
  return d;
}
ULL poww(ULL v, ULL p, ULL mod) {
  if (p == 0) return 1;
  if (p & 1) {
    return (poww(v, p - 1, mod) * v) % mod;
  } else {
    ULL t = poww(v, p / 2, mod);
    return (t * t) % mod;
  }
}
constexpr ULL L31018 = 3000000000000000000L;
constexpr ULL L1018 = 1000000000000000000L;
constexpr int MAXN = 5003;
int n;
int arr[MAXN];
int st;
int was[MAXN];
int l[MAXN];
int r[MAXN];
PI get_range(int v) {
  int lindex = v;
  int res = 0;
  int rindex = r[arr[lindex]];
  for (; lindex <= rindex; ++lindex) {
    if (was[arr[lindex]] == v) {
      continue;
    }
    was[arr[lindex]] = v;
    if (l[arr[lindex]] != lindex) {
      res = -INF;
      break;
    }
    res ^= arr[lindex];
    rindex = ((rindex < r[arr[lindex]]) ? (r[arr[lindex]]) : (rindex));
  }
  return std::make_pair(res, lindex);
}
int dp[MAXN];
int wasdp[MAXN];
int func(int v) {
  if (v > n) {
    return 0;
  }
  if (wasdp[v] == 1) {
    return dp[v];
  }
  wasdp[v] = 1;
  int res = func(v + 1);
  int tmp = 0;
  PI tmpget = get_range(v);
  if (tmpget.first >= 0) {
    tmp = tmpget.first + func(tmpget.second);
  }
  return dp[v] = ((tmp < res) ? (res) : (tmp));
}
void accept() {
  cin >> n;
  for (int i = (0); i < (MAXN); ++i) {
    l[i] = INF;
    r[i] = 0;
  }
  for (int i = (1); i < (n + 1); ++i) {
    scanf("%d", arr + i);
    l[arr[i]] = ((l[arr[i]] < i) ? (l[arr[i]]) : (i));
    r[arr[i]] = i;
  }
  cout << func(1);
}
int main(void) {
  accept();
  return 0;
}
