#include <bits/stdc++.h>
using namespace std;
int n;
int a[200010];
int totalDigits[30];
int curDigits[30];
void doBinary(int num) {
  for (int i = 0; i < 30; i++) curDigits[i] = 0;
  int p = 0;
  while (num > 0) {
    curDigits[p] = num % 2;
    num = num / 2;
    p++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &(a[i]));
    doBinary(a[i]);
    for (int j = 0; j < 30; j++) {
      totalDigits[j] = totalDigits[j] + curDigits[j];
    }
  }
  long long total = 0;
  long long curNum;
  for (int i = 0; i < n; i++) {
    curNum = 0;
    for (int j = 29; j >= 0; j--) {
      if (totalDigits[j] > 0) {
        curNum = curNum * 2 + 1;
        totalDigits[j]--;
      } else {
        curNum = curNum * 2;
      }
    }
    total = total + curNum * curNum;
  }
  printf("%I64d\n", total);
  return 0;
}
