#include <bits/stdc++.h>
int main() {
  unsigned long long int n, v, i, j;
  int m;
  scanf("%d", &m);
  for (j = 0; j < m; j++) {
    scanf("%I64d", &n);
    v = (n * (n + 1)) / 2;
    for (i = 1; i <= n; i = i * 2) {
      v = v - 2 * i;
    }
    printf("%I64d\n", v);
  }
  return 0;
}
