#include <bits/stdc++.h>
using namespace std;
long long mlog2(long long n) {
  long long ret = 0;
  while (n > 1) {
    n /= 2;
    ret++;
  }
  return ret;
}
long long solve(long long n) { return powl(2LL, n + 1) - 1; }
long long dnc(long long n) {
  if (n < 1) return 0;
  long long p = mlog2(n);
  long long mod = n - (1LL << p);
  return solve(p) + dnc(mod);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T = 1;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    cout << dnc(n) << "\n";
  }
}
