#include <bits/stdc++.h>
using namespace std;
struct aman {
  long long l;
  long long r;
  long long x;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long a[n];
  map<long long, vector<long long>> mp;
  map<long long, pair<long long, long long>> mp1;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]].push_back(i);
  }
  vector<aman> vect;
  set<long long> st1;
  for (long long i = 1; i <= n; i++) {
    long long l = -1;
    long long r = -1;
    set<long long> st;
    auto p1 = mp[a[i]];
    if (p1[0] == i) {
      long long z = p1.size() - 1;
      st.insert(a[i]);
      l = i;
      r = p1[z];
      long long j = i + 1;
      while (j <= n and j < r) {
        auto p2 = mp[a[j]];
        long long z2 = p2.size() - 1;
        if (p2[0] < i) {
          l = -1;
          r = -1;
          break;
        } else {
          r = max(p2[z2], r);
          st.insert(a[j]);
        }
        j++;
      }
    }
    if (l != -1 and r != -1) {
      long long x = 0;
      for (auto z : st) {
        x = x ^ z;
      }
      vect.push_back({l, r, x});
    }
  }
  long long dp[n + 1];
  memset(dp, 0, sizeof(dp));
  for (auto i : vect) {
    pair<long long, long long> p3 = {i.l, i.x};
    mp1[i.r] = p3;
  }
  for (long long i = 1; i <= n; i++) {
    if (mp1.count(i)) {
      dp[i] = max(dp[i - 1], mp1[i].second + dp[mp1[i].first - 1]);
    } else {
      dp[i] = max(dp[i], dp[i - 1]);
    }
  }
  cout << dp[n] << '\n';
  return 0;
}
