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