#include <bits/stdc++.h>
using namespace std;
long long oneToNseries(long long D, long long K) {
  long long top = (pow(D, K + 1) - 1);
  long long down = D - 1;
  return (top / down);
}
int main() {
  int nCase;
  long long N;
  scanf("%d", &nCase);
  for (int cs = 1; cs <= nCase; cs++) {
    scanf("%I64d", &N);
    long long total = N * (N + 1) / 2;
    long long cnt = 0;
    while (true) {
      if (pow(2, cnt) > N) {
        cnt--;
        break;
      }
      cnt++;
    }
    long long rem = oneToNseries(2, cnt);
    rem = rem * 2;
    printf("%I64d\n", total - rem);
  }
}
