#include <bits/stdc++.h>
using namespace std;
const int N = 1123;
const long long inf = 1e18;
long long two_p[64];
long long Ans[64];
void solve_case() {
  long long n;
  cin >> n;
  long long re = 0;
  int i = 0;
  while (n) {
    if (n & 1) {
      re += Ans[i];
    }
    n >>= 1;
    i++;
  }
  cout << re << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  int last = log2(1e18) + 1;
  two_p[0] = 1;
  for (int i = 1; i <= last; i++) {
    two_p[i] = 2 * two_p[i - 1];
  }
  Ans[0] = 1;
  for (int i = 1; i < last; ++i) {
    long long x = 0;
    for (int j = 1; j <= i; ++j) {
      x += two_p[i - j] * j;
    }
    x += (i + 1);
    Ans[i] = x;
  }
  while (t--) solve_case();
}
