#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < (int)t; ++i) {
    int n;
    cin >> n;
    long long ans = n * 1ll * (n + 1) / 2;
    for (int c = 1; c <= n; c *= 2) {
      ans -= c * 2;
    }
    cout << ans << '\n';
  }
  return 0;
}
