#include <bits/stdc++.h>
using namespace std;
int ans[5002];
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 1; i <= n; i++) cin >> a[i];
  int flag1[5001] = {};
  int flag3[5001] = {};
  for (int i = n; i >= 1; i--) {
    if (flag1[a[i]])
      continue;
    else
      flag1[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (flag3[a[i]]) continue;
    flag3[a[i]] = i;
  }
  for (int i = n; i >= 1; i--) {
    int h = 0;
    int u = 0;
    int flag2[5001] = {};
    int flag4[5001] = {};
    for (int i = 0; i <= 5000; i++) flag4[i] = 2;
    for (int j = i; j <= n; j++) {
      if (!flag2[a[j]]) {
        u ^= a[j];
        h++;
        flag2[a[j]] = 1;
      }
      if (flag1[a[j]] == j) {
        flag4[a[j]]--;
      }
      if (flag3[a[j]] == j) {
        flag4[a[j]]--;
      }
      if (flag4[a[j]] == 0) {
        h--;
      }
      if (h == 0) {
        ans[i] = max(u + ans[j + 1], ans[i]);
      }
    }
    ans[i] = max(ans[i], ans[i + 1]);
  }
  cout << ans[1];
}
