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