#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n], ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int k = 0;
  for (long long int i = 0; i < 32; i++) {
    k = 0;
    for (long long int j = 0; j < n; j++) {
      if (a[j] & (1 << i)) k++;
    }
    ans += ((1 << i) * k * (n - k));
  }
  cout << ans;
  return 0;
}
