提交时间:2022-08-09 11:33:41

运行 ID: 55128

#include <bits/stdc++.h> using namespace std; #define int unsigned long long int n,Max,ans; int a[20001]; bool bit[20001][21]; signed main() { scanf("%llu",&n); for(int i = 1;i <= n;i++) scanf("%llu",&a[i]); sort(a + 1,a + 1 + n); for(int i = 1;i <= n;i++) { int xx = a[i] | a[n]; int yy = a[i] & a[n]; a[n] = xx; a[i] = yy; } for(int i = 1;i <= n;i++) ans += a[i] * a[i]; printf("%llu\n",ans); return 0; }