#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
template <class T>
void clr(T& a, int n) {
  a.clear();
  a.resize(n + 1);
}
void solve();
const int N = 2e5 + 10;
const int INF = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
int n;
void solve() {
  cin >> n;
  vector<long long> a(n + 1);
  for (int i = int(1); i <= int(n); i++) {
    cin >> a[i];
  }
  const int B = 20;
  vector<long long> count(B + 1);
  for (int i = int(1); i <= int(n); i++) {
    for (int j = int(0); j <= int(B); j++) {
      long long mask = (1ll << j);
      count[j] += (mask & a[i] ? 1 : 0);
    }
  }
  debug() << " ["
          << "count"
             ": "
          << (count) << "] ";
  long long ans = 0;
  for (int i = int(1); i <= int(n); i++) {
    long long curr = 0;
    for (int j = int(0); j <= int(B); j++) {
      if (count[j] == 0) continue;
      curr += (1ll << j);
      count[j]--;
    }
    ans += curr * curr;
  }
  cout << ans << '\n';
}
