#include <bits/stdc++.h>
using namespace std;
inline bool isvowel(char ch) {
  ch = tolower(ch);
  return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
inline bool isprime(int n) {
  if (n < 2 || (n % 2 == 0 && n != 2)) return false;
  for (int i = 3; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
class Union {
 private:
  vector<int> saizu, link;

 public:
  Union(int n) {
    saizu.assign(n, 1);
    link.resize(n);
    iota(link.begin(), link.end(), 0);
  }
  int find(int n) {
    if (link[n] == n) return n;
    return link[n] = find(link[n]);
  }
  int same(int a, int b) { return find(a) == find(b); }
  void unite(int a, int b) {
    if (same(a, b)) return;
    a = find(a);
    b = find(b);
    if (saizu[a] < saizu[b]) swap(a, b);
    saizu[a] += saizu[b];
    link[b] = a;
  }
  int getsize(int a) { return saizu[find(a)]; }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  vector<long long> pref(61);
  pref[0] = 0;
  for (int i = 1; i < 61; i++) {
    pref[i] = pref[i - 1] * 2 + i;
  }
  while (t--) {
    long long n, ans = 0, lvl = 60;
    cin >> n;
    while (1) {
      if (n == (1ll << lvl) - 1) {
        ans += pref[lvl];
        break;
      } else if (n < (1ll << (lvl - 1)) - 1) {
        lvl--;
      } else if (n == (1ll << (lvl - 1)) - 1) {
        ans += pref[lvl - 1];
        break;
      } else if (n == (1ll << (lvl - 1))) {
        ans += pref[lvl - 1] + lvl;
        break;
      } else if (n > (1ll << (lvl - 1))) {
        ans += pref[lvl - 1] + lvl;
        n -= (1ll << (lvl - 1));
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
