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