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