#include <bits/stdc++.h>
int main() {
  long long n, s;
  for (std::cin >> n; std::cin >> n;
       s = n * (n + 1) / 2 - 2 * (pow(2, floor(log(n) / log(2)) + 1) - 1),
       std::cout << s << "\n")
    ;
}
