#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  cin >> t;
  while (t-- > 0) {
    long long n;
    cin >> n;
    long long sum = 1;
    long long pro = 1;
    while (n > 1) {
      if (pro * 2 <= n) {
        pro *= 2;
        sum += pro;
      } else {
        sum += 1;
        pro = 1;
        int k = 63;
        while (k >= 0) {
          if (n & (1LLU << k)) {
            long long p = 1LLU << k;
            n = (n & ~p);
            break;
          }
          k--;
        }
      }
    }
    if (n % 2 == 0) sum -= 1;
    cout << sum << endl;
  }
}
