#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T>
using vec = std::vector<T>;
template <class T>
vec<T> makeVec(const int n1, const T initValue) {
  return vec<T>(n1, initValue);
}
bool __hack = std::ios::sync_with_stdio(false);
auto __hack1 = cin.tie(nullptr);
struct Input {
  Input(istream &in) : in(&in) {}
  template <class T>
  T next() const {
    T x;
    *in >> x;
    return x;
  }
  int ni() const { return next<int>(); }
  template <class T>
  vec<T> nVec(int n) const {
    vec<T> v(n);
    for (int i = 0; i < n; ++i) {
      v[i] = next<T>();
    }
    return v;
  }
  vec<int> nvi(int n) const { return nVec<int>(n); }
  istream *in;
};
Input in(cin);
class Output {
 private:
  ostream *out;
  template <typename T>
  void printSingle(const T &value) {
    *out << value;
  }

 public:
  Output(ostream &out) : out(&out) {}
  inline void print() {}
  template <typename T, typename... Ts>
  inline void print(const T &f, const Ts &...args) {
    printSingle(f);
    if (sizeof...(args) != 0) {
      *out << ' ';
      print(args...);
    }
  }
  template <typename... Ts>
  inline void println(const Ts &...args) {
    print(args...);
    *out << '\n';
  }
  template <typename... Ts>
  inline void operator()(const Ts &...args) {
    println(args...);
  }
};
Output out(cout);
namespace template_util {
constexpr int bytecount(uint64_t x) { return x ? 1 + bytecount(x >> 8) : 0; }
template <int N>
struct bytetype {};
template <uint64_t N>
struct minimal_uint : bytetype<bytecount(N)> {};
}  // namespace template_util
void solve(istream &inStream, ostream &outStream) {
  in = Input(inStream);
  out = Output(outStream);
  auto n = in.ni();
  auto a = in.nvi(n);
  auto maxElement = *max_element(a.begin(), a.end());
  auto range = makeVec<pair<int, int>>(maxElement + 1, {-1, -1});
  for (int i = 0; i < (n); ++i) {
    if (range[a[i]].first == -1) {
      range[a[i]].first = i;
    }
    range[a[i]].second = i;
  }
  const int INF = numeric_limits<int>::max() / 2;
  vec<int> dp(n + 1, 0);
  dp[0] = 0;
  for (int i = (1); i <= (n); ++i) {
    unordered_set<int> bad;
    int xorValue = 0;
    dp[i] = max(dp[i], dp[i - 1]);
    for (int j = (i); j >= (1); --j) {
      bad.insert(a[j - 1]);
      if (range[a[j - 1]].first >= j - 1 && range[a[j - 1]].second <= i - 1) {
        bad.erase(a[j - 1]);
        xorValue ^= a[j - 1];
      }
      if (bad.empty()) {
        ;
        ;
        dp[i] = max(dp[i], xorValue + dp[j - 1]);
      }
    }
  }
  out(dp[n]);
}
int main() {
  solve(cin, cout);
  return 0;
}
