#include <bits/stdc++.h>
using namespace std;
const long long max_n = 4e5 + 20;
long long n, m, k, ans;
long long a[max_n];
vector<long long> v;
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x, p = 1;
    cin >> x;
    while (p <= x) p *= 2;
    cout << (x * (x + 1) / 2) - 2 * p + 2 << endl;
  }
  return 0;
}
