#include <bits/stdc++.h>
using namespace std;
int l[5100], r[5100], num[5100], n, vis[5100], val[5100], dp[5100], vis2[5100],
    mnum;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &num[i]);
    if (l[num[i]] == 0) l[num[i]] = i;
    r[num[i]] = i;
    vis[num[i]] = 1;
    mnum = max(mnum, num[i]);
  }
  for (int i = 1; i < mnum + 1; i++) {
    if (vis[i]) {
      int ll = l[i], rr = r[i], pan = 0;
      while (1) {
        pan = 0;
        for (int j = ll; j < rr + 1; j++) {
          if (l[num[j]] < ll) {
            pan = 1;
            ll = l[num[j]];
          }
          if (r[num[j]] > rr) {
            pan = 1;
            rr = r[num[j]];
          }
        }
        if (!pan) break;
      }
      r[i] = rr;
      l[i] = ll;
    }
  }
  for (int i = 1; i < mnum + 1; i++) {
    memset(vis2 + 1, 0, sizeof(vis2));
    if (vis[i]) {
      int now = i;
      vis2[i] = 1;
      for (int j = l[i]; j < r[i] + 1; j++) {
        if (!vis2[num[j]]) {
          now = now ^ num[j];
          vis2[num[j]] = 1;
        }
      }
      val[i] = now;
    }
  }
  for (int i = 1; i < mnum + 1; i++) {
    if (vis[i] && r[i] == 1) dp[1] = max(val[i], dp[1]);
  }
  for (int i = 2; i < n + 1; i++) {
    dp[i] = dp[i - 1];
    for (int j = 1; j < mnum + 1; j++) {
      if (vis[j]) {
        int rr = r[j], ll = l[j];
        if (rr == i) dp[i] = max(dp[i], val[j] + dp[ll - 1]);
      }
    }
  }
  printf("%d", dp[n]);
  return 0;
}
