#include <bits/stdc++.h>
using namespace std;
int main() {
  short n;
  cin >> n;
  while (n--) {
    long long a;
    cin >> a;
    long long s = (1 + a) * a / 2;
    long long q = 0;
    for (long long j = 1; j <= a; j *= 2) {
      q += j;
    }
    long long r = s - 2 * q;
    cout << r << "\n";
  }
  return 0;
}
