#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, m, i, j, k, x, y, z, h;
  cin >> t;
  while (t--) {
    cin >> n;
    long long ans = 1, x = 2, count = 2;
    while (x <= n) {
      y = (n - x) / (2 * x) + 1;
      ans += (count + 1) * y;
      x *= 2;
      count++;
    }
    if (n % 2 == 0) ans--;
    cout << ans << endl;
  }
}
