#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long sum = (n) * (n + 1) / 2;
  long long highPower = pow(2ll, (long long)log2(n) + 1) - 1;
  sum -= 2 * highPower;
  cout << sum << endl;
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
