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