#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
const long double PI = acos((long double)(-1));
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  vector<long long> a(n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  vector<long long> cnt(22);
  for (int bit = 0; bit <= 21; bit++) {
    for (int i = 0; i < n; i++) {
      if (a[i] >> bit & 1) {
        cnt[bit]++;
      }
    }
  }
  long long res = 0;
  vector<long long> b(n);
  for (int bit = 0; bit <= 21; bit++) {
    for (int i = 0; i < cnt[bit]; i++) {
      b[i] |= (1 << bit);
    }
  }
  for (int i = 0; i < n; i++) res += b[i] * b[i];
  cout << res << endl;
  return 0;
}
