#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int save[61];
    for (int i = 0; i < 60; ++i) {
      save[i] = (1LL << (i + 1)) - 1;
    }
    long long int ctr = 0;
    long long int ans = 0;
    while (n > 0) {
      if (n % 2 == 1) {
        ans += save[ctr];
      }
      ctr++;
      n >>= 1;
    }
    cout << ans << endl;
  }
  return 0;
}
