#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
const int MOD = 1000000007;
const int N = 100005;
void solve() {
  long long int pw = 2, ans = 0, n, xx = 1;
  cin >> n;
  while (pw / 2 <= n) {
    ans += xx;
    long long int diff = n - pw / 2;
    diff /= pw;
    ans += diff * xx;
    pw *= 2LL;
    xx++;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long int t = 1;
  cin >> t;
  for (long int tt = 1; tt <= t; tt++) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
