#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
struct edge {
  int to;
};
using graph = vector<vector<edge>>;
int bc[22];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    int ai;
    cin >> ai;
    for (int j = 0; j < (22); ++j) {
      if (ai % 2) bc[j]++;
      ai >>= 1;
    }
  }
  ll ans = 0;
  for (int i = 0; i < (n); ++i) {
    ll curr = 0;
    for (int j = 0; j < (22); ++j)
      if (bc[j]) {
        curr += 1 << j;
        bc[j]--;
      }
    ans += curr * curr;
  }
  cout << ans << "\n";
}
