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