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