#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    n++;
    unsigned long long int v = 1;
    unsigned long long int res = 0;
    unsigned long long int t = 0;
    while (n > v) {
      t = n / v + (n % v != 0) - 1;
      res += t;
      v = v << 1;
    }
    cout << res << "\n";
  }
}
