#include <bits/stdc++.h>
using namespace std;
vector<int> V;
vector<pair<int, int>> B;
deque<int> D;
map<string, int> mp;
set<int> S;
long long n, m, a, b, c, d, e, f, cnt = 1, ans;
string s;
char q, w, r;
int aru[132];
int arr[124];
char z;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    f = 0, cnt = 1;
    ans = (m * (m + 1)) / 2;
    while (cnt <= m) {
      f += cnt;
      cnt *= 2;
    }
    f *= 2;
    cout << ans - f << endl;
  }
}
