#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int count[21] = {0};
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 21; ++j) {
      if ((a[i] / (long long int)pow(2, j)) % 2 == 1) {
        count[j]++;
      }
    }
  }
  long long int ans[n];
  for (int i = 0; i < n; ++i) {
    long long int temp = 0;
    for (int j = 0; j < 21; ++j) {
      if (count[j] > 0) {
        temp += pow(2, j);
        count[j]--;
      }
    }
    ans[i] = temp;
  }
  long long int maxsum = 0;
  for (int i = 0; i < n; ++i) {
    maxsum += ans[i] * ans[i];
  }
  cout << maxsum << endl;
}
