#include <bits/stdc++.h>   using namespace std;   long long a[31];   int main() {     long long t, n;     long long q = 0;     cin >> t;     for (int i = 0; i <= 29; i++) {       a[i] = pow(2, i);     }     for (int i = 1; i <= t; i++) {       cin >> n;       if (n % 2 == 0) {         q = (n + 1) * (n / 2);       } else {         q = ((n / 2) + 1) * n;       }       for (int i = 0; i <= 29; i++) {         if (a[i] <= n) {           q = q - (a[i] * 2);         } else {           break;         }       }       cout << q << endl;       q = 0;     }     return 0;   }   