#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int MAXN = 1e7 + 125;
const long long INF = 1e9 + 7;
const long long MOD = (1 << 16);
const long long MOD1 = (1 << 30);
void file() {
  freopen(
      "choose"
      ".in",
      "r", stdin);
  if (0)
    freopen(
        "choose"
        ".out",
        "w", stdout);
}
int a[2012], b[2000];
long long i;
long long result;
long long fac(long long n) {
  if (n == 1 || n == 0) return 1;
  i++;
  cout << "step = " << i << endl;
  result = n * fac(n - 1);
  cout << "result = " << result << endl;
  return result;
}
long long fib(long long n) {
  if (n == 1 || n == 2) return n - 1;
  return fib(n - 1) + fib(n - 2);
}
int Aman(int a) {
  if (a < 1) return 0;
  a--;
  cout << a << endl;
  return Aman(a);
}
long long n, m, ans;
vector<pair<int, int>> q;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  long long n;
  long long sump = 0;
  while (t--) {
    cin >> n;
    sump = (n * (n + 1)) / 2;
    for (int i = 1; i <= n; i *= 2) {
      sump -= 2 * i;
    }
    cout << sump;
    cout << endl;
  }
  return 0;
}
