#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int test;
  cin >> test;
  while (test--) {
    long long int num;
    cin >> num;
    long long int res = num * (num + 1) / 2;
    long long int k = 1;
    while (k <= num) {
      res = res - (k * 2);
      k *= 2;
    }
    cout << res << endl;
  }
}
