#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
int a[N];
long long b[N];
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < 21; i++) {
    int cnt = 0;
    for (int j = 1; j <= n; j++)
      if ((a[j] >> i) & 1) cnt++;
    for (int j = 1; j <= cnt; j++) b[j] |= (1 << i);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += b[i] * b[i];
  cout << ans << '\n';
  return 0;
}
