#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, b[101];
  cin >> n;
  long long t, max = 0;
  for (int i = 0; i < n; i++) {
    cin >> t;
    b[i] = t;
    if (t > max) max = t;
  }
  vector<long long> a(32, 0);
  int k = 1;
  int i = 0;
  int q;
  while (k <= max) {
    a[i] = k;
    i++;
    k = k * 2;
  }
  long long s = 0;
  for (int j = 0; j < n; j++) {
    s = 0;
    i = 0;
    t = b[j];
    if (t == 1) {
      cout << -1 << endl;
    } else {
      long long r = 1;
      while (a[i] * 2 <= t) {
        r = a[i];
        i++;
      }
      r = r * 2;
      s = ((1 + t) * t / 2) - (2 * (1 - r * 2) / (1 - 2));
      cout << s << endl;
    }
  }
}
