#include <bits/stdc++.h>
using namespace std;
int l[5001], r[5001], dp[5003][5003], a[5001], n, Xor[5003][5003], r1[5003];
void cal_xor() {
  for (int i = 0; i < n; i++) {
    unordered_map<int, int> mp;
    for (int j = i; j < n; j++) {
      if (i == j)
        Xor[i][j] = a[i], mp[a[i]] = 1;
      else {
        if (!mp.count(a[j]))
          Xor[i][j] = Xor[i][j - 1] ^ a[j], mp[a[j]] = 1;
        else
          Xor[i][j] = Xor[i][j - 1];
      }
    }
  }
}
void cal_right() {
  for (int i = 0; i < n; i++) {
    if (l[a[i]] != i) continue;
    int right = r[a[i]];
    for (int j = i; j < n && j <= right; j++) {
      if (l[a[j]] < l[a[i]]) {
        right = n;
        break;
      }
      right = max(right, r[a[j]]);
    }
    r1[a[i]] = right;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) r[a[i]] = i;
  for (int i = n - 1; i >= 0; i--) l[a[i]] = i;
  cal_xor();
  cal_right();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j + i < n; j++) {
      if (i == 0 && l[a[j]] == r[a[j]])
        dp[j][j + i] = a[j];
      else {
        if (l[a[j]] == j && r1[a[j]] <= j + i)
          dp[j][j + i] = Xor[j][r1[a[j]]] + dp[r1[a[j]] + 1][j + i];
        dp[j][j + i] = max(dp[j][j + i], dp[j + 1][j + i]);
      }
    }
  }
  cout << dp[0][n - 1];
}
