#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t, i;
  cin >> t;
  long long n, c, m;
  long long a[61];
  a[0] = 0;
  a[1] = 1;
  for (int j = 2; j < 61; j++) {
    a[j] = 2 * a[j - 1] + j;
  }
  while (t--) {
    cin >> n;
    c = 0;
    while (n > 0) {
      i = 0;
      m = 1;
      while ((m << 1) <= n) {
        m = m << 1;
        i++;
      }
      c += a[i] + i + 1;
      n = n - m;
    }
    cout << c << "\n";
  }
}
