#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
template <typename T1, typename T2>
inline void chmin(T1 &a, const T2 &b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, const T2 &b) {
  if (a < b) a = b;
}
lint solve(lint n) {
  lint b = 1;
  lint ans = 0;
  for (int i = 0; i < 60; i++) {
    ans += n / b;
    b *= 2;
  }
  return ans;
}
lint naive(lint n) {
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int diff = 0;
    for (int v = 0; v < 18; v++) {
      if ((i & (1 << v)) != ((i - 1) & (1 << v))) {
        diff++;
      }
    }
    sum += diff;
  }
  return sum;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    lint n;
    cin >> n;
    cout << solve(n) << endl;
  }
  return 0;
}
