#include <bits/stdc++.h>
using namespace std;
vector<long long> dv;
int binpow(int a, int n) {
  if (n == 0)
    return 1;
  else {
    if (n % 2 != 0)
      return binpow(a, n - 1) * a;
    else {
      int b = binpow(a, n / 2);
      return b * b;
    }
  }
}
int main() {
  int t;
  long long ans = 0;
  dv.resize(32);
  for (int i = 0; i < 31; i++) {
    dv[i] = binpow(2, i);
  }
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (n == 1)
      cout << -1 << endl;
    else {
      ans = 0;
      long long y = 0;
      for (int j = 0; j < 32; j++) {
        if (dv[j] <= n) {
          y += 2 * dv[j];
        } else
          break;
      }
      if (n % 2 == 0)
        for (int i = 1; i * 2 <= n; i++) {
          ans += i, ans += n - i + 1;
        }
      else
        for (int i = 1; i * 2 - 1 <= n; i++) {
          ans += i, ans += n - i;
        }
      cout << ans - y << endl;
    }
  }
  return 0;
}
