#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, a[101], b[101], ans = 0, j = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    cin >> a[i];
    ans = 0;
    j = 1;
    ans = a[i] * (a[i] + 1) / 2;
    while (j <= a[i]) {
      ans -= j * 2;
      j *= 2;
    }
    b[i] = ans;
  }
  for (int i = 1; i <= t; i++) {
    cout << b[i] << endl;
  }
  return 0;
}
