#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int minu = 1, temp = 0, n, ans = 0;
    cin >> n;
    ans = ((n) * (n + 1)) / 2;
    while (minu <= n) {
      temp += minu;
      minu *= 2;
    }
    ans -= (2 * temp);
    cout << ans << "\n";
  }
  return 0;
}
