#include <bits/stdc++.h>
int main() {
  long long int t, sum, ar[32], n, c;
  for (int i = 0; i <= 31; i++) {
    ar[i] = pow(2, i);
  }
  scanf("%lld", &t);
  for (int i = 0; i < t; i++) {
    sum = 0, c = 0;
    scanf("%lld", &n);
    for (int i = 0; i < 31; i++) {
      if (ar[i] <= n) {
        c++;
      }
    }
    for (int i = 0; i < c; i++) {
      sum = sum + ar[i];
    }
    long long int final = 0;
    final = ((n * (n + 1)) / 2) - (2 * sum);
    printf("%lld\n", final);
  }
}
