#include <bits/stdc++.h>
using namespace std;
const int mxn = 5005, m = 5000;
int n, s[mxn], l[mxn], r[mxn], f[mxn], g[mxn], d[mxn][mxn];
int main() {
  cin >> n;
  memset(d, 0xcf, sizeof d);
  for (int i = 0; i <= m; ++i) l[i] = n + 1, r[i] = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    l[s[i]] = min(l[s[i]], i);
    r[s[i]] = max(r[s[i]], i);
  }
  for (int i = 1; i <= n; ++i) {
    int x = i, y = i, z = 0;
    for (int j = 0; j <= m; ++j) g[j] = 0;
    for (int j = i; j <= n; ++j) {
      x = min(x, l[s[j]]);
      y = max(y, r[s[j]]);
      if (!g[s[j]]) z ^= s[j], g[s[j]] = 1;
      if (i <= x && y <= j) d[i][j] = z;
    }
  }
  for (int i = 1; i <= n; ++i) {
    f[i] = f[i - 1];
    for (int j = 1; j <= i; ++j) f[i] = max(f[i], f[j - 1] + d[j][i]);
  }
  cout << f[n] << endl;
}
