#include <bits/stdc++.h>
using namespace std;
int main() {
  { cout << fixed << setprecision(15); }
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<long long> ct(40);
  for (int i = 0; i < n; i++) {
    int j = 0;
    while (v[i] != 0) {
      ct[j] += v[i] % 2;
      v[i] /= 2;
      j++;
    }
  }
  vector<long long> ans(n);
  long long t = 1;
  for (int i = 0; i < 40; i++) {
    for (int j = 0; j < ct[i]; j++) {
      ans[j] += t;
    }
    t *= 2;
  }
  long long an = 0;
  for (int i = 0; i < n; i++) {
    an += ans[i] * ans[i];
  }
  cout << an << '\n';
  return 0;
}
