#include <bits/stdc++.h>
using namespace std;
long long a1, an, Sn, n, raodenoba, Snb, q = 2, bn = 1, i, jami;
int main() {
  cin >> raodenoba;
  for (i = 1; i <= raodenoba; i++) {
    cin >> an;
    a1 = 1;
    n = an;
    Sn = ((a1 + an) * n) / 2;
    bn = 1;
    while (bn < an) {
      bn = bn * 2;
    }
    if (bn > an) bn = bn / 2;
    Snb = (bn * q - a1) / (q - 1);
    jami = Sn - (2 * Snb);
    cout << jami << " ";
  }
}
