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