#include <bits/stdc++.h>
using namespace std;
const int maxx = 200010;
unsigned long long t, n;
unsigned long long ans = 0, total = 0, sum = 0;
unsigned long long a[maxx], b[maxx], bj[maxx];
int main() {
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld", &n);
    ans = 0, total = 0, sum = 1;
    while (n >= sum) {
      unsigned long long opt = sum;
      total++;
      sum *= 2;
      ans += total + (n - opt) / sum * total;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
