#include <bits/stdc++.h>
using namespace std;
inline char get_char() {
  static char buf[10000001], *p1 = buf, *p2 = buf;
  return p1 == p2 &&
                 (p2 = (p1 = buf) + fread(buf, 1, 10000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long num = 0;
  char c;
  while (isspace(c = get_char()))
    ;
  while (num = num * 10 + c - 48, isdigit(c = get_char()))
    ;
  return num;
}
long long lower(long long a) {
  long long res = 1;
  a = a / 2;
  while (res <= a) res *= 2;
  return res;
}
long long getans(long long a) {
  if (a == 0) return 0;
  long long res = lower(a);
  return 2 * res - 1 + getans(a - res);
}
int main() {
  int n = read();
  long long res[n];
  for (int i = 0; i < n; i++) {
    long long m = read();
    long long ret = getans(m);
    res[i] = ret;
  }
  for (int i = 0; i < n; i++) cout << res[i] << "\n";
}
