#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n), b(n), count(20);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int bit = 0; bit < 20; bit++) {
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 1) count[bit]++;
      a[i] /= 2;
    }
  }
  for (int bit = 19; bit >= 0; bit--) {
    for (int j = 0; j < n; j++) {
      b[j] *= 2;
      if (count[bit]) {
        b[j] += 1;
        count[bit]--;
      }
    }
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += b[i] * b[i];
  }
  cout << sum << "\n";
}
int main(void) {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
