#include <bits/stdc++.h>
using namespace std;
int main() {
  long long in, temp = 0, t = 0;
  int casos;
  cin >> casos;
  for (int i = 0; i < casos; i++) {
    cin >> in;
    temp = in * (in + 1) / 2;
    for (long long i = 0;; i++) {
      if ((1 << i) > in) {
        break;
      } else {
        long long j = 1 << i;
        t = t + j;
      }
    }
    temp = temp - 2 * t;
    cout << temp << endl;
    t = 0;
    temp = 0;
  }
  return 0;
}
