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