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