#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  vector<ll> vec;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    ll x;
    cin >> x;
    vec.push_back(x);
  }
  ll ans = 0;
  for (int i = 0; i < 60; i++) {
    ll z = 0, o = 0;
    for (int j = 0; j < n; j++) {
      if (((vec[j] >> i) & 1) == 1) {
        o++;
      } else
        z++;
    }
    ans += o * z * (1 << i);
  }
  cout << ans << endl;
}
