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