#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;

int main()
{
    long long int n,t,k,sum=0;
    cin>>t;

    while(t--)
    {
    cin>>n;
    cout<<n*(n-1)/2<<endl;

    }
    return 0;
}

