#include <bits/stdc++.h>
using namespace std;
long int PS_Nve[30];
int main() {
  PS_Nve[0] = 1;
  for (int i = 1; i < 30; i++) PS_Nve[i] = PS_Nve[i - 1] + pow(2, i);
  int t, x;
  long long n, sum;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n;
    x = log2(n);
    sum = n * (1 + n) / 2;
    cout << sum - PS_Nve[x] * 2 << endl;
  }
}
