#include <iostream>using namespace std;int main(){ int t; cin>>t; for(int k=1;k<=t;++k) { int n; cin>>n; cout<< (n*(n-1))/2<<endl; }}