#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long a[N];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long sum = (n * (n + 1)) >> 1;
    for (int i = 0; i <= 30; i++) {
      long long yo = (1LL << i);
      if (yo <= n) sum -= (yo << 1);
    }
    cout << sum << "\n";
  }
  return 0;
}
