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