#include <bits/stdc++.h>
using namespace std;
long long p[50];
int main() {
  p[0] = 1;
  for (int i = 1; i <= 40; ++i) p[i] = p[i - 1] * 2;
  int t;
  cin >> t;
  for (int j = 1; j <= t; ++j) {
    long long n, k = 0;
    cin >> n;
    long long s = ((n * (n + 1))) / 2;
    while (n > 0) {
      n /= 2;
      k++;
    }
    for (int i = 0; i < k; ++i) s -= (2 * p[i]);
    cout << s << endl;
  }
  return 0;
}
