#include <bits/stdc++.h>
using namespace std;
long long fast_pow(long long base, long long power) {
  long long res = 1;
  while (power > 0) {
    if (power & 1) {
      res = res * base;
    }
    base = base * base;
    power = power / 2;
  }
  return res;
}
int main() {
  vector<int> v;
  int x = 0;
  while (x < 30) {
    int ans = fast_pow(2, x);
    v.push_back(ans);
    x++;
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long res;
    res = (long long)n * (long long)(n + 1) / 2;
    int i = 0;
    while (v[i] <= n && i < 30) {
      res -= 2 * v[i];
      i++;
    }
    cout << res << endl;
  }
  return 0;
}
