#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int cnt[20];
  for (int i = 0; i < 20; i++) {
    cnt[i] = 0;
    for (int j = 0; j < n; j++)
      if ((a[j] >> i) & 1) cnt[i]++;
  }
  long long ans = 0;
  while (1) {
    int curr = 0;
    for (int i = 0; i < 20; i++) {
      if (cnt[i] > 0) {
        curr = curr + (1 << i);
        cnt[i]--;
      }
    }
    ans += (long long)curr * curr;
    if (curr == 0) break;
  }
  cout << ans << endl;
  return 0;
}
