#include <bits/stdc++.h>
using namespace std;
int a[200005];
int f[200005];
int Cnt[200005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    for (int j = 20; ~j; --j)
      if (1 << j & a[i]) f[++Cnt[j]] |= 1 << j;
  long long Ans = 0;
  for (int i = 1; i <= n; ++i) Ans += 1ll * f[i] * f[i];
  printf("%lld\n", Ans);
  return 0;
}
