Rt
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int ans=0,a[100005];
signed main(){
freopen("andor.in","r",stdin);
freopen("andor.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
srand((unsigned)time(0));
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
ans+=a[i]*a[i];
}
while((double)clock()/CLOCKS_PER_SEC<0.93){
int x=rand()*rand()%n+1,y=rand()*rand()%n+1;
if(x==y) continue;
int p1=a[x]&a[y],p2=a[x]|a[y];
ans=ans-a[x]*a[x]-a[y]*a[y]+p1*p1+p2*p2;
a[x]=p1,a[y]=p2;
}
cout<<ans<<"\n";
return 0;
}