#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
long long pw(long long x) {
  long long ssm = 1;
  for (long long i = 0; i < x; i++) {
    ssm *= 2;
  }
  return ssm;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    mp.clear();
    long long sum = 0;
    long long n;
    cin >> n;
    sum = (1 + n) * n / 2;
    for (int i = 0; i <= 31; i++) {
      if (pw(i) > n) break;
      sum -= 2 * pw(i);
    }
    cout << sum << endl;
  }
  return 0;
}
