#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int t_;
  cin >> t_;
  while (t_--) {
    unsigned long long n;
    cin >> n;
    unsigned long long zeros = (n + 1) / 2 + (n + 1) % 2;
    unsigned long long ones = n + 1 - zeros;
    unsigned long long result = zeros;
    for (unsigned long long i = 1; ones != 0 && i <= 63; i++) {
      unsigned long long ones2 = ones / 2 + ones % 2;
      ones -= ones2;
      result += ones2 * (i + 1);
    }
    result--;
    while (n % 2 != 0) {
      n /= 2;
      result--;
    }
    cout << result << endl;
  }
  return 0;
}
