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