#include <bits/stdc++.h>
using namespace std;
unsigned long long q1[70] = {0, 3, 7, 15, 31};
int main() {
  unsigned long long T, n, ans, a, b;
  cin >> T;
  for (int i = 4; i < 64; i++) {
    q1[i] = q1[i - 1] * 2 + 1;
  }
  while (T--) {
    cin >> n;
    ans = 0;
    while (n > 0) {
      if (n == 1) {
        ans++;
        break;
      }
      for (unsigned long long i = 0; i < 64; i++) {
        if (n >> i == 0) {
          a = i;
          ans += q1[i - 1];
          break;
        }
      }
      b = n - ((n >> (a - 1)) << (a - 1));
      n = b;
    }
    cout << ans << '\n';
  }
}
