#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, fin = 0, d = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    fin = ((n * (n + 1)) / 2);
    while ("wael") {
      fin -= (2 * d);
      d *= 2;
      if (d > n) break;
    }
    cout << fin << endl;
    d = 1;
  }
  return 0;
}
