#include <bits/stdc++.h>
using namespace std;
long long expo(int base, long long pwr) {
  long long ans = 1, i;
  for (i = 0; i < pwr; i++) ans = ans * 2;
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long temp = n, bits = 0;
    while (temp != 1) {
      temp /= 2;
      bits++;
    }
    long long ans = 2 * (expo(2, bits) - 1) - bits;
    ans += bits + 1;
    bits = n - expo(2, bits);
    long long i;
    for (i = 0; i <= log2(bits); i++) {
      ans =
          ans + (i + 1) * ceil(double(bits - expo(2, i) + 1) / expo(2, i + 1));
    }
    cout << ans << endl;
  }
}
