#include <bits/stdc++.h>
using namespace std;
long long tab[70];
void Tab() {
  for (int i = 0; i < 64; i++) tab[i] = pow(2, i);
}
long long Sum(long long n) {
  long long m = n + 1;
  if ((long long)(m) % 2 == 0)
    m /= 2;
  else
    n /= 2;
  long long sum = m * n;
  return sum;
}
long long Sum1(long long n) {
  long long sum1 = pow(2, n) - 1;
  return sum1;
}
int Find(long long n) {
  int i = 0;
  for (; i < 64; i++) {
    if (tab[i] > n) break;
  }
  return i;
}
int main() {
  Tab();
  long long ans, sum, sum1;
  int t;
  long long n;
  cin >> t;
  while (t--) {
    ans = 0;
    cin >> n;
    sum = Sum(n);
    long long site = Find(n);
    sum1 = Sum1(site);
    ans = sum - sum1 - sum1;
    printf("%lld\n", ans);
  }
  return 0;
}
