#include <bits/stdc++.h>
using namespace std;
long long am[20];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    cin >> a[i];
    for (int j = 0, ThxDem = 20; j < ThxDem; ++j)
      if (a[i] & (1 << j)) am[j]++;
    a[i] = 0;
  }
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    for (int j = 0, ThxDem = 20; j < ThxDem; ++j)
      if (am[j]) a[i] |= 1 << j, am[j]--;
  }
  long long ans = 0;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) ans += a[i] * a[i];
  cout << ans << "\n";
}
