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