#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int MINF = 0x80000000;
const int mod = 1000000007;
const int cons = 100001;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long n;
    scanf("%I64d", &n);
    long long sum = n * (n + 1) / 2;
    for (int i = 0; (1LL << i) <= n; i++) {
      sum -= 2 * (1LL << i);
    }
    printf("%I64d\n", sum);
  }
  return 0;
}
