#include <bits/stdc++.h>
using namespace std;
long long arr[70];
int main() {
  arr[0] = 1;
  for (long long i = 1; i <= 60; i++) {
    for (int j = 0; j < i; j++) {
      arr[i] += arr[j];
    }
    arr[i] += i + 1;
  }
  int t;
  scanf("%d", &t);
  while (t--) {
    long long x, sum = 0;
    ;
    scanf("%lld", &x);
    while (x) {
      int bit = 63 - __builtin_clzll(x);
      sum += arr[bit];
      x ^= (1ll << bit);
    }
    printf("%lld\n", sum);
  }
  return 0;
}
