#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, sum = 0;
    cin >> n;
    for (int i = 0; i < 60; i++) {
      long long x = 1LL << i;
      if (n & x) {
        sum += (1LL << (i + 1)) - 1;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
