#include <bits/stdc++.h>
int main() {
  long long int n;
  scanf("%I64d", &n);
  while (n--) {
    long long int num;
    scanf("%I64d", &num);
    long long int ans = (num + 1) * num / 2;
    int i = 1;
    while (i <= num) {
      ans -= i * 2;
      i *= 2;
    }
    printf("%I64d\n", ans);
  }
}
