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