#include <bits/stdc++.h>
using namespace std;
long long solve() {
  long long n;
  cin >> n;
  long long a[n], b[20] = {0};
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    for (long long j = 0; j < 20; j++) {
      if ((a[i] >> j) & 1) b[j]++;
    }
  }
  long long ans = 0;
  while (1) {
    long long m = 0;
    for (long long j = 0; j < 20; j++) {
      if (b[j] > 0) {
        m = m + (1 << j);
        b[j]--;
      }
    }
    if (m == 0) break;
    ans = ans + m * m;
  }
  cout << ans;
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
