#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long x = (n * (n + 1)) / 2;
    long long q = 1;
    long long c = 1;
    for (c = 1; c < 100000; c++) {
      q = q * 2;
      if (q > n) break;
    }
    long long yy = c;
    long long r = 1;
    for (long long z = 0; z < yy; z++) r = r * 2;
    long long rr = (r - 1);
    cout << x - 2 * rr << '\n';
  }
}
