#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  long long n, sum1, sum2, sumF;
  cin >> t;
  while (t--) {
    cin >> n;
    sum1 = (n * (n + 1)) / 2;
    sum2 = 0;
    for (long long i = 1;; i = i * 2) {
      if (i > n) break;
      sum2 = sum2 + i;
    }
    sumF = sum1 - (2 * sum2);
    cout << sumF << endl;
  }
  return 0;
}
