#include <bits/stdc++.h>
using namespace std;
string toString(long long n) {
  stringstream second;
  second << n;
  return second.str();
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n, sum;
    cin >> n;
    sum = n * (n + 1) / 2;
    long long int pow2 = 1;
    while (pow2 <= n) {
      sum -= 2 * pow2;
      pow2 *= 2;
    }
    cout << sum << '\n';
  }
  return 0;
}
