#include <bits/stdc++.h>
using namespace std;
char p[30] = {'0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
              'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
              'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
inline long long rd() {
  long long x = 0, flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * flag;
}
int t;
long long n;
inline int lowbit(int x) { return x & (-x); }
int main() {
  t = rd();
  while (t--) {
    n = rd();
    long long x = 63;
    long long ans = 0;
    for (; x >= 0; x--) {
      if (n & (1ll << x)) {
        ans += (1ll << (x + 1ll)) - 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
