#include <bits/stdc++.h>
using namespace std;
int count(int x) {
  int ret = 0;
  while (x) {
    if (x & 1) ret++;
    x >>= 1;
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  long long a[100010];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long BIT[1001] = {0};
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int val = 0;
    int idx = 1 + count(a[i]);
    for (; idx > 0; idx = idx - (idx & (-idx))) val += BIT[idx];
    for (idx = count(a[i]); idx > 0; idx -= (idx & (-idx))) val -= BIT[idx];
    for (idx = 1 + count(a[i]); idx < 1001; idx += (idx & (-idx))) BIT[idx]++;
    ans += val;
  }
  cout << ans << endl;
  return 0;
}
