1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<queue>
5 #include<cmath>
6 #include<algorithm>
7 #include<cstdlib>
8 #define ll long long
9 using namespace std;
10 int read(){
11 int x=0,f=1;char ch=getchar();
12 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
13 while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
14 return x*f;
15 }
16 bool cmp(int a,int b){return a>b;}
17 int n,a[105],b[35];
18 ll tot,ans;
19 int main(){
20 n=read();
21 for(int i=1;i<=n;i++)a[i]=read();
22 sort(a+1,a+1+n,cmp);
23 for(int i=1;i<=n;i++)tot+=1ll*a[i];
24 for(int i=1;i<=n;i++){
25 int t=a[i];
26 for(int j=30;j>=0;j--){
27 if(a[i]&(1<<(j-1))){
28 if(!b[j]){b[j]=i;break;}
29 else a[i]^=a[b[j]];
30 }
31 }
32 if(a[i])ans+=1ll*t;
33 }
34 printf("%lld\n",tot-ans);
35 return 0;
36 }