#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<long long> num_bits(20);
  for (long long i = 0; i < 20; i++) {
    num_bits[i] = 0;
  }
  for (long long i = 0; i < n; i++) {
    string bin = bitset<20>(arr[i]).to_string();
    for (long long j = 0; j < bin.size(); j++) {
      if (bin[j] == '1') {
        num_bits[j]++;
      }
    }
  }
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    long long pot = 0;
    for (long long j = 0; j < num_bits.size(); j++) {
      if (num_bits[j] != 0) {
        pot += (long long)pow(2, 19 - j);
        num_bits[j]--;
      }
    }
    res += (long long)pot * pot;
  }
  cout << res << endl;
}
