#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    long long a;
    cin >> a;
    long long sum = 0;
    sum += a * (a + 1) / 2;
    for (int i = 0;; i++) {
      long long ans = (long long)pow(2, i);
      if (ans > a) break;
      sum -= 2 * ans;
    }
    cout << sum << endl;
  }
}
