#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long sum = (n * (n + 1)) / 2;
    for (long long i = 0; i < 32; i++) {
      if ((1 << i) > n)
        break;
      else
        sum -= (2 * (1 << i));
    }
    cout << sum << "\n";
  }
  return 0;
}
