#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, t, sum = 0, pdt = 1;
    int count = 0;
    cin >> n;
    t = n;
    while (t > 0) {
      t = t >> 1;
      count++;
    }
    sum = (n * (n + 1)) / 2;
    while (count > 0) {
      pdt = pdt * 2;
      count--;
    }
    pdt = pdt * 2 - 2;
    cout << sum - pdt << endl;
  }
  return 0;
}
