#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int mx = log2(n);
    long long sum1 = 1LL * n * (n + 1) / 2LL;
    long long sum2 = 2LL * (pow(2, mx + 1) - 1);
    cout << sum1 - sum2 << "\n";
  }
}
