#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long dp[100] = {0};
  long long ans = 0;
  while (true) {
    long long i = 1;
    dp[0] = 0;
    while (pow(2, i) - 1 <= n) {
      dp[i] = pow(2, i) - 1 + dp[i - 1];
      i++;
    }
    i--;
    ans += dp[i];
    if (pow(2, i) - 1 == n) break;
    ans += i + 1;
    n -= pow(2, i);
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test;
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
