#include <bits/stdc++.h>
int main() {
  long long int n, i, j, k, t, s = 0, num, a, b;
  scanf("%lld", &t);
  for (i = 1; i <= t; i++) {
    scanf("%lld", &n);
    s = 0;
    if (n == 1) {
      printf("-1\n");
    } else if (n == 2) {
      printf("-3\n");
    } else {
      num = 2;
      s = -3;
      for (j = 1;; j++) {
        num *= 2;
        if (num > n) {
          break;
        } else if (num <= n) {
          a = (num / 2);
          s += (((num - 1) * (num)) / 2) - ((a * (a + 1)) / 2);
          s -= num;
        }
      }
      if ((num - n) != (num / 2)) {
        a = num / 2;
        s += ((n * (n + 1)) / 2) - ((a * (a + 1)) / 2);
      }
      printf("%lld\n", s);
    }
  }
  return 0;
}
