#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
long long int dp[70];
void solve() {
  for (long long int i = 0; i <= 63; i++) {
    dp[i] = pow(2, i + 1) - 1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    set<long long int> s;
    s.clear();
    for (long long int i = 63; i >= 0; i--) {
      if (pow(2, i) <= n) {
        s.insert(i);
        long long int x = pow(2, i);
        n = n % x;
      }
    }
    long long int ans = 0;
    for (auto i : s) {
      ans += dp[i];
    }
    cout << ans << endl;
  }
  return 0;
}
