#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  long long n;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld", &n);
    long long sum1 = 0, sum2;
    long long tt = 1;
    while (n >= tt) {
      sum1 += tt;
      tt <<= 1;
    }
    sum2 = n * (n + 1) / 2 - sum1;
    printf("%lld\n", sum2 - sum1);
  }
  return 0;
}
