#include <bits/stdc++.h>
using namespace std;
const long long maxm = 1e18;
long long tpow[105];
void init() {
  tpow[1] = 2;
  for (int i = 2;; i++) {
    tpow[i] = tpow[i - 1] * 2;
    if (tpow[i] > maxm) break;
  }
}
int main() {
  init();
  int t;
  scanf("%d", &t);
  while (t--) {
    long long n, sum = 0, cnt = 1;
    scanf("%lld", &n);
    while (n) {
      if (n & 1) sum += tpow[cnt] - 1;
      n >>= 1;
      cnt++;
    }
    printf("%lld\n", sum);
  }
  return 0;
}
