#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, k, m, s;
  cin >> m;
  while (m--) {
    cin >> n;
    t = n;
    k = n;
    while (n) {
      t = n & -n;
      if (t)
        n = n & ~t;
      else
        break;
    }
    s = (k * (k + 1)) / 2;
    s = s - 2 * (t * 2 - 1);
    cout << s << endl;
  }
}
