#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long INF64 = (long long)1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
long long n;
bool read() { return (cin >> n).good(); }
void solve() {
  long long sum = n * (n + 1) / 2;
  for (long long i = 1; i <= n; i *= 2) {
    sum -= i * 2;
  }
  cout << sum << endl;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    read();
    solve();
  }
  return 0;
}
