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