#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<cmath>
#include<iostream>
using namespace std;
#define maxn 50000
const int mod = 1e9+7;
typedef __int64 LL;
LL sum[maxn];
LL mu[maxn];
void init()
{
mu[1]=1;
for(int i=2; i<maxn; i++)
{
sum[i]=sum[i-1]+i;
mu[i]=(mu[i-1]*i)%mod;
}
sum[1]=1;
}
LL mult(LL a,int n)
{
LL ans=1;
while(n)
{
if(n&1)ans=(ans*a)%mod;
a=(a*a)%mod;
n>>=1;
}
return ans;
}
int main()
{
init();
int T;
scanf("%d",&T);
while(T--)
{
LL x;
scanf("%I64d",&x);
int index=lower_bound(sum,sum+maxn,x)-sum;
LL ans;
if(sum[index]==x)
ans=mu[index];
else
{
if(sum[index]==x+1)
ans=((mu[index+1]*mult(index,mod-2))%mod*mult(2,mod-2))%mod;
else
ans=(mu[index]*mult(sum[index]-x,mod-2))%mod;
}
printf("%I64d\n",ans);
}
return 0;
}