提交时间:2022-08-09 11:39:39
运行 ID: 55148
#include<bits/stdc++.h> #define ll long long #define N 200005 using namespace std; int n,cnt[25];ll x[N],ans; int main(){ // freopen("basis.in","r",stdin); // freopen("basis.out","w",stdout); scanf("%d",&n); for(int i(1);i<=n;++i){ int a;scanf("%d",&a); for(int k(0);a;++k,a>>=1) cnt[k]+=(a&1); } for(int k(0);k<=20;++k) for(int i(1);i<=cnt[k];++i) x[i]|=(1<<k); for(int i(1);i<=n;++i) ans+=x[i]*x[i]; printf("%lld\n",ans); return 0; }