#include <bits/stdc++.h>
using namespace std;
const long long int MAX_N = 150000, inf = 1e16, mod = 1e9 + 7;
int32_t main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  long long int dp[100] = {};
  dp[0] = 0;
  for (long long int i = 1; i < 100; i++) dp[i] = 2 * dp[i - 1] + i;
  long long int t;
  cin >> t;
  while (t--) {
    long long int a;
    cin >> a;
    long long int ans = 0;
    while (a > 0) {
      long long int idx = 0;
      for (long long int i = 0; i < 100; i++) {
        if ((1ll << i) > a) {
          idx = i;
          break;
        }
      }
      idx -= 2;
      ans += dp[idx + 1];
      a -= (1ll << (idx + 1));
      ans += idx + 2;
    }
    cout << ans << endl;
  }
  return 0;
}
