#include <bits/stdc++.h>
using namespace std;
class compare {
 public:
  bool operator()(pair<long long, long long> a, pair<long long, long long> b) {
    if (a.first > b.first) return true;
    return false;
  }
};
bool comp(long long a, long long b) { return a > b; }
long long power(long long a, long long b) {
  long long res = 1;
  a = a;
  while (b) {
    if (b & 1) {
      res = (res * a);
    }
    b /= 2;
    a = (a * a);
  }
  return res;
}
int32_t main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long cnt[21] = {0};
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 21; j++) {
      if (a[i] & (1 << j)) {
        cnt[j]++;
      }
    }
  }
  vector<long long> res(n, 0);
  for (long long i = 0; i < n; i++) {
    for (long long j = 20; j >= 0; j--) {
      if (cnt[j] > 0) {
        res[i] |= (1 << j);
        cnt[j]--;
      }
    }
  }
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += (res[i] * res[i]);
  }
  cout << sum << endl;
}
