#include <bits/stdc++.h>
using namespace std;
int freq[30];
long long sum = 0;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  memset(freq, 0, sizeof freq);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    vector<int> dig;
    long long a;
    cin >> a;
    while (a > 0) {
      dig.push_back(a % 2);
      a /= 2;
    }
    for (int j = 0; j < dig.size(); j++) {
      if (dig[j]) {
        freq[j]++;
      }
    }
  }
  long long resp = 0;
  for (int i = 0; i < n; i++) {
    long long currsum = 0;
    for (int j = 25; j >= 0; j--) {
      if (false)
        cout << "frequencia do digito" << j << " = " << freq[j] << "\n";
      if (freq[j]) {
        freq[j]--;
        currsum += power(2LL, j);
      }
    }
    if (false) cout << "currsum = " << currsum << "\n";
    resp += currsum * currsum;
  }
  cout << resp << "\n";
}
