#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX = 0x7fffffff;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = 500000 + 5;
const int maxm = 100000 + 5;
const int mod = 1000000000 + 7;
long long n;
void indata() { cin >> n; }
void slove() {
  long long ans;
  if (n % 2 == 0) {
    ans = n / 2 * (n + 1);
  } else {
    ans = (n + 1) / 2 * n;
  }
  long long k = 1;
  while (k <= n) {
    ans -= k * 2;
    k <<= 1;
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    indata();
    slove();
  }
  return 0;
}
