#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long int p2 = 1, s = 0, t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << (n * n + n) / 2 - 2 * ((2 << (int)log2(n)) - 1) << '\n';
  }
  return 0;
}
