#include <bits/stdc++.h>
using namespace std;
long long solve() {
  long long n;
  cin >> n;
  long long sum = 0;
  for (int i = 63; i >= 0; i--) {
    if (n & (1ll << i)) {
      long long x = 1ll << i;
      long long j = 1;
      while (x > 0) {
        x >>= 1;
        sum += j * x;
        j++;
      }
      sum += (j - 1);
    }
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    cout << solve() << '\n';
  }
  return 0;
}
