#include <bits/stdc++.h>
const int MAX = 1e18;
const long long MOD = 1e9 + 7;
using namespace std;
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long result = power(a, b / 2);
  result *= result;
  if (b % 2) result *= a;
  return result;
}
string toBinary(long long n) {
  string r;
  while (n != 0) {
    r = (n % 2 == 0 ? "0" : "1") + r;
    n /= 2;
  }
  reverse(r.begin(), r.end());
  return r;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s = toBinary(n);
    long long sum = 0, x, y;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '1') {
        x = n + 1 + (power(2, i) - 1);
        y = pow(2, i + 1);
        sum += (x / y) * (i + 1);
      } else {
        x = n + 1;
        y = power(2, i + 1);
        sum += (x / y) * (i + 1);
      }
    }
    cout << sum << endl;
  }
  return 0;
}
