#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}
unordered_map<string, int> X;
long long get_sum(long long n) {
  if (n == 1) {
    return 1;
  }
  return get_sum(n / 2) + n;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, num;
  long long n, sum = 0, temp;
  string str;
  cin >> t;
  while (t--) {
    sum = 0;
    temp = 1;
    cin >> n;
    while (n > 0) {
      temp = 1;
      while (temp <= n) {
        temp *= 2;
      }
      sum += get_sum(temp / 2);
      n = n - (temp / 2);
    }
    cout << sum << endl;
  }
}
