#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j = 1, s;
  while (1) {
    if (j > INT_MAX) break;
    v.push_back(j);
    j = j << 1;
  }
  s = v.size();
  long long int test;
  cin >> test;
  while (test--) {
    long long int n;
    cin >> n;
    long long int ans;
    ans = (n * (n + 1)) >> 1;
    for (i = 0; i < s; i++) {
      if (v[i] <= n) ans -= (2 * v[i]);
    }
    cout << ans << endl;
  }
  return 0;
}
