#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = 0;
    for (long long i = 0; i < 64; i++) {
      if (n & (1ll << i)) {
        ans += (1ll << (i + 1)) - 1;
      }
    }
    cout << ans << endl;
  }
}
