#include <bits/stdc++.h>
using namespace std;
int Num_Queries;
long long int N, Sum_N, Log2, Result[100];
int main() {
  cin >> Num_Queries;
  for (int i = 0; i < Num_Queries; i++) {
    cin >> N;
    Sum_N = (N * (N + 1)) / 2;
    Log2 = pow(2, (floor(log2(N))) + 2) - 2;
    Result[i] = Sum_N - Log2;
  }
  for (int i = 0; i < Num_Queries; i++) cout << Result[i] << "\n";
  return 0;
}
