#include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 1;
int cmpfunc(const void *a, const void *b) { return *(int *)a - *(int *)b; }
long long int a[N];
int main() {
  long long int temp = 1;
  a[1] = temp;
  for (int i = 2; temp < int(1e9) + 10; i++) {
    a[i] = a[i - 1] + temp * 2;
    temp *= 2;
  }
  int t;
  scanf("%d", &t);
  while (t--) {
    long long int n;
    cin >> n;
    int temp = n, ct = 0;
    while (temp) {
      ct++;
      temp >>= 1;
      ;
    }
    printf("%lld\n", (n * (n + 1)) / 2 - 2 * a[ct]);
  }
  return 0;
}
