#include <bits/stdc++.h>
using namespace std;
long long n, lista[200100], pot[200], final[200100];
void solve() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> lista[i];
  sort(lista + 1, lista + n + 1);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= 20; j++) {
      long long l = (1 << j);
      if (l & lista[i]) {
        pot[j]++;
      }
    }
  }
  for (long long j = 0; j <= 20; j++) {
    for (long long l = 1; l <= pot[j]; l++) {
      final[l] += (1 << j);
    }
  }
  long long resp = 0;
  for (long long i = 1; i <= n; i++) resp += final[i] * final[i];
  cout << resp;
}
signed main() { solve(); }
