#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x, a;
    cin >> a;
    x = (a % 2 == 0 ? (a / 2) * (1 + a) : ((a + 1) / 2) * a);
    for (long long j = 1; j <= a; j *= 2) {
      x -= 2 * j;
    }
    cout << x << endl;
  }
  return 0;
}
