#include <bits/stdc++.h>
using namespace std;
string tostr(long long a) {
  stringstream rr;
  rr << a;
  return rr.str();
}
long long pow(long long c, long long d) { return d == 0 ?: c * pow(c, d - 1); }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
int main() {
  long long n, m, k, i, j, x, y, p = 0, s = 0, h, f = 0;
  cin >> n;
  long long b[22];
  memset(b, 0, sizeof(b));
  for (i = 1; i <= n; i++) {
    cin >> m;
    j = 0;
    while (m > 0) {
      k = m % 2;
      b[j] += k;
      m /= 2;
      j++;
    }
  }
  while (1) {
    x = 0;
    for (i = 0; i <= 20; i++) {
      k = 1LL << i;
      if (b[i] > 0) {
        x += k;
        b[i]--;
      }
    }
    if (x == 0) break;
    p += (x * x);
  }
  cout << p << endl;
  return 0;
}
