#include <bits/stdc++.h>
using namespace std;
int cnt[30];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    for (long long j = 0; j <= 20; j++) {
      if (x & ((long long)1 << j)) cnt[j]++;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long now = 0;
    for (long long j = 0; j <= 20; j++) {
      if (cnt[j]) {
        now = now + ((long long)1 << j);
        cnt[j]--;
      }
    }
    ans += (now * now);
  }
  cout << ans << '\n';
  return 0;
}
