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