#include <bits/stdc++.h>
using namespace std;
int n;
int a[200010];
int mask[100];
long long res;
signed main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= 30; ++j)
      if ((a[i] >> j) & 1) ++mask[j];
  }
  for (int i = 30; i >= 0; --i) {
    if (mask[i] == 0) continue;
    for (int j = 1; j <= mask[i]; ++j) {
      long long tmp = (1ll << i);
      for (int t = i - 1; t >= 0; --t) {
        if (mask[t] == 0) continue;
        tmp += (1ll << t);
        mask[t]--;
      }
      res += tmp * tmp;
    }
  }
  cout << res;
}
