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