#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long long n;
    cin >> n;
    long long s = n * (n + 1) / 2;
    double a = log2(double(n));
    a = floor(a);
    s -= 2 * (int(pow(2.0, a + 1)) - 1);
    cout << s << endl;
  }
  return 0;
}
