#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, n, j, max1 = 0;
  cin >> n;
  vector<long long int> v2(100, 0);
  for (i = 0; i < n; i++) {
    long long int a1;
    cin >> a1;
    j = 0;
    while (a1 != 0) {
      long long int a3 = a1 % 2;
      v2[j] = v2[j] + a3;
      j++;
      a1 = a1 / 2;
    }
    if (j > max1) max1 = j;
  }
  long long int result = 0;
  max1--;
  long long int res = 0, a3, max2;
  while (1) {
    max2 = 10000000;
    res = 0;
    for (j = max1; j >= 0; j--) {
      if (v2[j] < max2 && v2[j] > 0) max2 = v2[j];
    }
    if (max2 == 10000000) break;
    for (j = max1; j >= 0; j--) {
      if (v2[j] >= max2) {
        v2[j] = v2[j] - max2;
        res = res + pow(2, j);
      }
    }
    result += (res * res) * (max2);
  }
  cout << result;
}
