#include <bits/stdc++.h>
using namespace std;
bool isPowerOf2(long long n) {
  while (n % 2 == 0) n /= 2;
  if (n == 1) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long long n;
    cin >> n;
    long long sum = (n * (n + 1)) / 2;
    for (int i = 1; i <= n; i *= 2) {
      sum -= i * 2;
    }
    cout << sum << "\n";
  }
}
