#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long n, k;
  long long sum, ex;
  for (int i = 1; i <= t; i++) {
    ex = 1;
    cin >> n;
    k = log2(n);
    sum = (n * (n + 1) / 2);
    for (int j = 1; j <= (k + 1); j++) {
      ex = ex * 2;
    }
    ex -= 1;
    cout << sum - (2 * ex) << endl;
  }
}
