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