#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
const int N = 2e5 + 5, MOD = 1e9 + 7;
const long double EPS = 1e-9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long i, n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long f[32] = {};
  for (i = 0; i < n; i++) {
    for (long long j = 0; j < 22; j++) {
      f[j] += ((a[i] & (1ll << j)) > 0);
    }
  }
  vector<long long> b(n);
  for (i = 0; i < n; i++) {
    b[i] = 0;
    for (long long j = 0; j < 22; j++) {
      if (f[j]) {
        b[i] += pow(2, j);
        f[j]--;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) ans += b[i] * b[i];
  cout << ans;
  return 0;
}
