#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, ans = 0;
  cin >> n;
  ans = (n) * (n + 1) / 2;
  for (int j = 0; (long long)pow(2, j) <= n; j++) {
    ans -= (2 * (long long)pow(2, j));
  }
  cout << ans << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
