#include <bits/stdc++.h>
using namespace std;
int work(int x) {
  int apple = 0;
  for (int i = 1; i <= x; i = i * 2) {
    apple += i;
  }
  return apple;
}
int main() {
  int T, n;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    long long int ans = n;
    long long int ans1 = (ans + 1) * ans / 2;
    long long int ans2 = work(n);
    ans1 = ans1 - 2 * ans2;
    printf("%I64d\n", ans1);
  }
  return 0;
}
