#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
const long long int MODA = 1000000007;
vector<long long int> primefactors;
vector<long long int> factors;
long long int fact[1025] = {};
bool isPowerTwo(long long int x) { return (x && !(x & (x - 1))); }
bool isSubstring(string s1, string s2) {
  if (s1.find(s2) != string::npos)
    return true;
  else
    return false;
}
void generateFactorial(long long int n) {
  fact[0] = 1;
  for (long long int i = 1; i <= n; i++)
    fact[i] = (i * 1ll * fact[i - 1]) % MODA;
}
bool isPrime(long long int n) {
  if (n < 2) return false;
  for (long long int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MODA;
    a = (a * a) % MODA;
    b >>= 1;
  }
  return res;
}
long long int modi(long long int a) {
  long long int m = MODA, s = 1, p = 0;
  while (a > 1) {
    long long int q = a / m, t = m;
    m = a % m;
    a = t;
    t = p;
    p = s - q * p;
    s = t;
  }
  return s >= 0 ? s : s + MODA;
}
void generatePrimeFactors(long long int n) {
  primefactors.clear();
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      primefactors.push_back(i);
      while (n % i == 0) n = n / i;
    }
  }
  if (n != 1) primefactors.push_back(n);
}
long long int ncr(long long int n, long long int r) {
  if (r == 0) return 1;
  fact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % MODA;
  return (fact[n] * modi(fact[r]) % MODA * modi(fact[n - r]) % MODA) % MODA;
}
void generateFactors(long long int n) {
  factors.clear();
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      factors.push_back(i);
      if (n / i != i) factors.push_back(n / i);
    }
  }
  factors.push_back(1);
  factors.push_back(n);
  sort(factors.begin(), factors.end());
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int i, j, n, m;
  cin >> n;
  long long int sum = 0, num = 0, temp = 0, a;
  vector<long long int> bits(20, 0);
  for (i = 0; i < n; i++) {
    cin >> a;
    j = 0;
    while (a) {
      if (a % 2 == 1) bits[j]++;
      a = a / 2;
      j++;
    }
  }
  while (num < n) {
    temp = 0;
    for (i = 0; i < 20; i++) {
      if (bits[i] > 0) {
        temp += 1 << i;
        bits[i]--;
      }
    }
    sum += temp * temp;
    num++;
  }
  cout << sum;
  return 0;
}
