#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double E = exp(1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
const int MOD = 142857;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = n * (n + 1) / 2;
    for (int i = 0;; ++i) {
      long long temp = 1 << i;
      if (temp > n) break;
      ans -= 2 * temp;
    }
    cout << ans << endl;
  }
  return 0;
}
