#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const long long INFL = (long long)9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const long long MAXLL = ((~0) ^ ((long long)1 << 63));
template <class T>
inline T pow2(T a) {
  return a * a;
}
template <class T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, true) : false;
}
template <class T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, true) : false;
}
const int maxn = 4e5;
long long n, a, b[40], t, c[maxn], pw[40];
int main() {
  ios_base::sync_with_stdio(0);
  pw[0] = 1;
  for (int i = 1; i <= 30; i++) pw[i] = pw[i - 1] * 2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    t = 0;
    while (a > 0) {
      if (a % 2) b[t]++;
      a /= 2;
      t++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 30; j++) {
      if (b[j]) {
        c[i] += pw[j];
        b[j]--;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += c[i] * c[i];
  cout << ans;
  return 0;
}
