#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  std::vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  std::vector<long long> b(n);
  for (int i = 0; i <= 20; i++) {
    long long cnt = 0;
    for (int j = 0; j < n; j++) {
      cnt += ((v[j] >> i) & 1);
    }
    for (int j = 0; j < cnt; j++) {
      b[j] |= 1 << i;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += b[i] * b[i];
  }
  cout << ans << "\n";
  return 0;
}
