#include <bits/stdc++.h>
int pow(int a, int b) {
  int res = 1;
  for (int i = 0; i < b; i++) res *= a;
  return res;
}
int main(void) {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    long long int res = (long long int)n * (n + 1) / 2;
    int p = 0;
    for (int m = 1; m <= n; m <<= 1, p++)
      ;
    p--;
    res -= 2 * (pow(2, p + 1) - 1);
    printf("%I64d\n", res);
  }
}
