#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000100;
bool task[MAX];
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long num = (n * (n + 1)) / 2;
    num -= 2;
    for (long long i = 2; i <= n; i *= 2) num -= (2 * i);
    cout << num << endl;
  }
}
