#include<bits/stdc++.h>
using namespace std;
long long arr[5001];
vector< vector<long long int> > v;
long long dp[5010],a[5010];
long long N;
int mx[5010],maxx[5010];
long long recurse(int x){
if(x>=N)
return 0;
long long ans=0;
if(dp[x]!=-1)
return dp[x];
long long val=0;
for(int i=x;i<N;i++){
if(mx[a[i]]>=x && maxx[a[i]]==i ){
val^=a[i];
}
ans=max(ans,val+recurse(i+1));
}
return dp[x]=ans;
}
int main(){
cin>>N;
int i,j;
for(i=0;i<5001;i++){
mx[i]=INT_MAX;
}
for(i=0;i<N;i++){
scanf("%lld",&a[i]);
mx[a[i]]=min(i,mx[a[i]]);
maxx[a[i]]=max(i,maxx[a[i]]);
dp[i]=-1;
}
cout<<recurse(0)<<endl;;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmxvbmcgbG9uZyBhcnJbNTAwMV07Cgp2ZWN0b3I8IHZlY3Rvcjxsb25nIGxvbmcgaW50PiA+IHY7CgoKbG9uZyBsb25nIGRwWzUwMTBdLGFbNTAxMF07CmxvbmcgbG9uZyBOOwppbnQgbXhbNTAxMF0sbWF4eFs1MDEwXTsKbG9uZyBsb25nIHJlY3Vyc2UoaW50IHgpewppZih4Pj1OKQpyZXR1cm4gMDsKbG9uZyBsb25nIGFucz0wOwoKaWYoZHBbeF0hPS0xKQpyZXR1cm4gZHBbeF07CmxvbmcgbG9uZyB2YWw9MDsKZm9yKGludCBpPXg7aTxOO2krKyl7CmlmKG14W2FbaV1dPj14ICYmIG1heHhbYVtpXV09PWkgKXsKICAgIHZhbF49YVtpXTsKfQphbnM9bWF4KGFucyx2YWwrcmVjdXJzZShpKzEpKTsKCn0KcmV0dXJuIGRwW3hdPWFuczsKfQoKaW50IG1haW4oKXsKY2luPj5OOwppbnQgaSxqOwpmb3IoaT0wO2k8NTAwMTtpKyspewogICAgbXhbaV09SU5UX01BWDsKfQpmb3IoaT0wO2k8TjtpKyspewpzY2FuZigiJWxsZCIsJmFbaV0pOwpteFthW2ldXT1taW4oaSxteFthW2ldXSk7Cm1heHhbYVtpXV09bWF4KGksbWF4eFthW2ldXSk7CmRwW2ldPS0xOwp9Cgpjb3V0PDxyZWN1cnNlKDApPDxlbmRsOzsKcmV0dXJuIDA7Cn0=