#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    int flag = 0;
    if (n % 2 == 0) {
      flag = 1;
      n--;
    }
    long long i = 1;
    long long ans = 0;
    long long temp = n;
    while (temp / i > 0) {
      ans += temp / i;
      if (temp / i == 1) break;
      i *= 2;
    }
    if (flag == 1) n++;
    if (n % 2 == 0) {
      long long num1 = n;
      long long num2 = n - 1;
      int b1 = 0, b2 = 0;
      while (num1 > 0 || num2 > 0) {
        b1 = num1 % 2;
        b2 = num2 % 2;
        if (b1 != b2) ans++;
        num1 /= 2;
        num2 /= 2;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
