#include <bits/stdc++.h>
using namespace std;
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool sortinrev(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first == b.first) return b.second > a.second;
  return a.first > b.first;
}
void run(vector<long long int> v) {
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
void solve() {
  int n;
  cin >> n;
  long long int a[n], b[21];
  memset(b, 0, sizeof(b));
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    vector<int> v;
    while (a[i] > 0) {
      v.push_back(a[i] % 2);
      a[i] = a[i] / 2;
    }
    for (int i = 0; i < v.size(); i++) b[i] += v[i];
  }
  int count = 0;
  vector<long long int> ans;
  for (auto x : b) count += x;
  while (count > 0) {
    long long int num = 0;
    for (int i = 0; i < 21; i++) {
      if (b[i] > 0) {
        num += (pow(2, i));
        b[i] -= 1;
        count--;
      }
    }
    ans.push_back(num);
  }
  long long int sum = 0;
  for (int i = 0; i < ans.size(); i++) sum += ans[i] * ans[i];
  cout << sum;
}
int main() {
  solve();
  return 0;
}
