#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long ans;
  while (t != 0) {
    long long n = 0;
    cin >> n;
    ans = 0;
    ans += (n * (n + 1)) / 2;
    ans -= 2 * ((long long)(pow(2, floor(log2(n)) + 1)) - 1);
    cout << ans << endl;
    t--;
  }
  return 0;
}
