#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, bit[30], a[maxn];
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    for (int j = 0; j <= 20; j++) {
      bit[j] += (a[i] & 1);
      a[i] = a[i] >> 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    int x = 0;
    for (int j = 0; j <= 20; j++) {
      if (bit[j]) {
        x = x + (1 << j);
        bit[j]--;
      }
    }
    ans += 1ll * x * x;
  }
  printf("%lld\n", ans);
  return 0;
}
