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