nim和线性基
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
int n, uu, ji[35], a[105];
ll ans;
int main(){
cin>>n;
for(int i=1; i<=n; i++)
scanf("%d", &a[i]);
sort(a+1, a+1+n);
for(int i=n; i>=1; i--){
int tmp=a[i];
for(int j=30; j>=0; j--)
if(a[i]&(1<<j)){
if(!ji[j]){
ji[j] = a[i];
break;
}
else a[i] ^= ji[j];
}
if(a[i]==0) ans += tmp;
}
cout<<ans<<endl;
return 0;
}