#include <bits/stdc++.h>
using namespace std;
long long mod = 1e19 + 7;
long long fpow(long long x, long long y) {
  if (y == 0) return 1;
  if (x == 1) return 1;
  if (x == 0) return 0;
  if (y == 1) return x;
  long long d = fpow(x, y / 2);
  d %= mod;
  if (y % 2) return (((d * d) % mod) * x) % mod;
  return (d * d) % mod;
}
long long c[70];
int main() {
  c[0] = 1;
  for (long long i = 1; i <= 65; i++) {
    c[i] = c[i - 1] * 2;
  }
  long long t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    long long m = n, j = 0, ans = 0;
    ;
    while (m > 0) {
      if (m % 2 == 1) {
        ans += (c[j + 1] - 1);
      }
      m /= 2;
      j++;
    }
    cout << ans << endl;
    ;
  }
}
