#include <bits/stdc++.h>
long long int q, i, j, k = 1, top, x, n, o, z;
int f(int a) {
  for (j = 1; j <= a; j++) k *= 2;
  return k;
}
int main() {
  scanf("%lld", &q);
  for (i = 0; i < q; i++) {
    scanf("%lld", &x);
    top = (x * (x + 1)) / 2;
    while (o <= 10000) {
      if (pow(2, o) <= x) {
        top -= f(o + 1);
      } else
        break;
      k = 1;
      o++;
    }
    k = 1;
    o = 0;
    printf("%lld\n", top);
  }
  return 0;
}
