#include <bits/stdc++.h>
using namespace std;
bool isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' ||
      c == 'E' || c == 'I' || c == 'O' || c == 'U')
    return true;
  return false;
}
bool prime[5000001];
int spf[5000001];
vector<int> primes;
void sieve() {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= 5000000; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= 5000000; i += p) {
        prime[i] = false;
        if (spf[i] == 0) spf[i] = p;
      }
    }
  }
  for (int p = 2; p <= 5000000; p++)
    if (prime[p]) primes.push_back(p);
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long fast_exp(long long x, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans *= x;
    n = n >> 1;
    x = x * x;
  }
  return ans;
}
long long mod_exp(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long power(long long x, long long y) {
  long long temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ones[30];
  memset(ones, 0, sizeof(ones));
  for (int i = 0; i < n; i++) {
    int count = 0;
    while (a[i] > 0) {
      if (a[i] % 2 != 0) ones[count]++;
      a[i] = a[i] >> 1;
      count++;
    }
  }
  for (int i = 0; i < 30; i++) {
    for (int j = 0; j < ones[i]; j++) {
      a[j] += power(2, i);
    }
  }
  long long answer = 0;
  for (int i = 0; i < n; i++) {
    answer += a[i] * a[i];
  }
  cout << answer << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
