#include <bits/stdc++.h>
using namespace std;
int arr[200200];
int fr[50] = {0};
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ma = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 22; j++) {
      if ((arr[i] & (1 << j)) != 0) {
        fr[j]++;
        ma = max(ma, fr[j]);
      }
    }
  }
  long long int ans = 0;
  vector<long long int> val(ma, 0);
  for (int i = 22; i >= 0; i--) {
    for (int j = 0; j < fr[i]; j++) {
      val[j] = val[j] | (1 << i);
    }
  }
  for (int i = 0; i < ma; i++) {
    ans = ans + (val[i] * val[i]);
  }
  cout << ans;
  return 0;
}
