#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long total = 0;
  for (long long i = 0; i < 60; i++) {
    long long cnt0 = 0;
    long long cnt1 = 0;
    for (long long j = 0; j < n; j++) {
      if ((a[j] >> i) & 1)
        cnt1++;
      else
        cnt0++;
    }
    long long sum = cnt0 * cnt1;
    for (long long j = 0; j < i; j++) sum *= 2;
    total += sum;
  }
  cout << total;
  return 0;
}
