#include <bits/stdc++.h>
using namespace std;
int n, a[5005], dp[5005], maks, pref[5005], l, sum;
pair<int, int> p[5005];
bitset<5005> b;
bool f;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i <= 5000; i++) {
    p[i].first = 1e6, p[i].second = 0;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p[a[i]].first = min(p[a[i]].first, i);
    p[a[i]].second = max(p[a[i]].second, i);
    pref[i] = pref[i - 1] ^ a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (p[a[i]].second == i) {
      l = p[a[i]].first, f = false, sum = 0;
      for (int j = 0; j <= 5000; j++) {
        b[j] = false;
      }
      for (int j = i; j >= l; j--) {
        if (p[a[j]].second != j && !b[a[j]]) {
          f = true;
          break;
        } else if (p[a[j]].second == j) {
          l = min(l, p[a[j]].first);
          b[a[j]] = true;
          sum ^= a[j];
        }
      }
      if (!f) {
        dp[i] = max(sum + dp[l - 1], dp[i - 1]);
      } else {
        dp[i] = dp[i - 1];
      }
    } else {
      dp[i] = dp[i - 1];
    }
    maks = max(maks, dp[i]);
  }
  cout << maks << '\n';
}
