#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = LLONG_MAX;
const long long LOG = 29;
const long long N = (1030);
long long fact[N];
long long binpow(long long a, long long b) {
  a %= MOD;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  res %= MOD;
  return res;
}
void ini() {
  fact[0] = 1;
  for (long long i = 1; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % MOD;
  }
}
long long ncr(long long n, long long r) {
  long long ret = fact[n];
  ret = (ret * binpow(fact[r], MOD - 2)) % MOD;
  ret = (ret * binpow(fact[n - r], MOD - 2)) % MOD;
  return ret;
}
map<long long, long long> cnt;
void solve() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (long long i = 0; i < 62; i++) {
    long long p = (1ll << i);
    if (p > n) break;
    long long p2 = (1ll << (i + 1));
    long long gg = i;
    gg++;
    ans += gg * ((n - p) / p2);
    ans += (gg);
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  long long tt = 1;
  cin >> tt;
  while (tt--) {
    solve();
  }
}
