#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long sum = 0;
    long long exp = 1;
    long long pow = -1;
    long long e = n;
    long long ans = 0;
    while (e > 0) {
      long long count = e / (exp * 2);
      if (e % (exp * 2) != 0) count++;
      ans += (count) * (pow + 2);
      sum += exp;
      exp *= 2;
      pow++;
      e = n - sum;
    }
    cout << ans << "\n";
  }
}
