#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    long long n;
    long long ans = 0, p = 1;
    cin >> n;
    n++;
    while (p <= n) {
      ans += (n + p - 1) / p - 1;
      p *= 2;
    }
    cout << ans << endl;
  }
}
