#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
void fun(long long N) {
  long long p = 1;
  while (N > 0) {
    mp[p] += (N % 2);
    p = p * 2;
    N = N / 2;
  }
}
int main() {
  long long N, k, ans = 0;
  cin >> N;
  for (long long i = 0; i < N; i++) {
    cin >> k;
    fun(k);
  }
  for (long long i = 0; i < N; i++) {
    k = 0;
    for (auto &x : mp) {
      if (x.second) {
        k += x.first;
        (x.second)--;
      }
    }
    ans += (k * k);
  }
  cout << ans << "\n";
}
