#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  scanf("%lld", &t);
  while (t--) {
    unsigned long long x;
    cin >> x;
    bitset<64> bst(x);
    string s = bst.to_string();
    reverse(s.begin(), s.end());
    while (s[s.size() - 1] != '1') s.pop_back();
    unsigned long long res = 0;
    x++;
    for (int i = 0; i < s.size(); i++) {
      unsigned long long temp = 0;
      unsigned long long powr = pow(2, i + 1);
      if (s[i] == '1') {
        if (powr > x)
          temp = 1;
        else {
          temp = x / powr;
          if (x % powr != 0) temp++;
        }
      } else
        temp = x / powr;
      res += (i + 1) * temp;
    }
    cout << res << endl;
  }
}
