#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i;
  long long res;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    res = 1ll * n * (n + 1) / 2;
    i = 1;
    while (i <= n) {
      res -= i << 1;
      i <<= 1;
    }
    printf("%I64d\n", res);
  }
  return 0;
}
