#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int64_t arr[64];
  for (int i = 0; i < 63; i++) {
    arr[i] = 2 * (pow(2, i) - 1) + 1;
  }
  for (int x = 0; x < t; x++) {
    int64_t n;
    cin >> n;
    int64_t sum = 0;
    for (int i = 62; i >= 0; i--) {
      int64_t p = pow(2, i);
      if (n >= p) {
        sum += arr[i];
        n = n - pow(2, i);
      }
    }
    cout << sum << endl;
  }
  return 0;
}
