#include <bits/stdc++.h>
using namespace std;
const char el = '\n';
long long dp[61];
void generate() {
  dp[0] = 0;
  dp[1] = 1;
  for (int k = 2; k <= 60; ++k) {
    dp[k] = dp[k - 1] * (long long)2;
    dp[k] += (long long)(k);
  }
}
long long solve(long long n) {
  if (n == 0) return 0;
  long long twopow = 1;
  int pow = 0;
  long long prevtwopow = 1;
  int prevpow = 0;
  while (twopow <= n) {
    prevtwopow = twopow;
    prevpow = pow;
    twopow *= (long long)2;
    ++pow;
  }
  return dp[prevpow] + (long long)(prevpow + 1) + solve(n - (prevtwopow));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  generate();
  int T;
  cin >> T;
  for (int t = 0; t < T; ++t) {
    long long n;
    cin >> n;
    cout << solve(n) << el;
  }
}
