#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const double EPS = 1e-7;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long res = n * (n + 1) / 2;
    for (long long i = 1; i <= n; i *= 2) {
      res -= 2 * i;
    }
    cout << res << endl;
  }
  return 0;
}
