#include <bits/stdc++.h>
using namespace std;
int a[35];
set<int> s;
int main() {
  long long z = 1;
  for (int i = 0; i <= 30; i++) {
    a[i] = z;
    s.insert(a[i]);
    z *= 2;
  }
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long long n;
    cin >> n;
    long long x = (n * (n + 1)) / 2, y = 0;
    for (int i = 30; i >= 0; i--)
      if (n >= a[i]) {
        y = i;
        break;
      }
    cout << x - (2 * (a[y + 1] - 1)) << "\n";
  }
  return 0;
}
