#include <bits/stdc++.h>
using namespace std;
const long long losn = 1e6 + 5;
const long long maxn = 1e5 + 5;
const long long minn = 1e3 + 5;
const long long tiny = 1e2 + 5;
const long long zlosn = 1e6;
const long long zmaxn = 1e5;
const long long zminn = 1e3;
const long long ztiny = 1e2;
const long long inf = 1e9;
const long long binf = 1e18;
const long long mod = 1e9 + 7;
const long long lmod = 998244353;
const long long hashmod = 4698571;
const long double pi = 3.1415926;
const long long myn = 0;
void gk() { cout << "---------------" << endl; }
void ck() { cout << 1 << endl; }
void ck(long long a) { cout << a << endl; }
void ck(long long a[minn][minn], long long n, long long m) {
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
}
long long n, m, k, T, u, v, len, s;
long long dp[maxn];
long long pre[maxn];
long long nums[maxn];
int main() {
  long long id = 0;
  long long s = 1;
  pre[0] = 1;
  pre[1] = 3;
  for (long long i = 0; i <= 65; i++) {
    ++id;
    if (i >= 1) {
      dp[i] += dp[i - 1] * 2;
    }
    dp[i] += (i + 1);
    if (i >= 2) {
      pre[i] = dp[i] - dp[i - 1];
    }
    nums[i] = s;
    s *= 2;
    if (s > binf) {
      break;
    }
  }
  long long t;
  cin >> t;
  while (t--) {
    long long ans = 0;
    cin >> n;
    for (long long i = id; i >= 0; i--) {
      if (n >= nums[i]) {
        ans += pre[i];
        n -= nums[i];
      }
    }
    ck(ans);
  }
  return 0;
}
