#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long> cnt(20);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 20; j++) {
      if (a[i] & (1 << j)) cnt[j]++;
    }
  }
  long long ans = 0;
  while (true) {
    bool ok = true;
    long long cur = 0;
    for (int i = 0; i < 20; i++) {
      if (cnt[i] != 0) {
        ok = false;
        cur += 1 << i;
        cnt[i]--;
      }
    }
    if (ok) break;
    ans += cur * cur;
  }
  cout << ans << endl;
}
