#include <iostream>
#include <array>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
const int MAX_N = 1e6 + 1;

array<ll,MAX_N> fact;

int max_fact=1;
ll factMod(ll n){
    if (n>=MOD) return 0;
    if (n<=max_fact) return fact[n];
    
    for (ll i=max_fact+1;i<=n;++i){
        fact[i]=fact[i-1]*i%MOD;
    }
    max_fact = n;
    return fact[n];
}

int main(){
    fact[0]=fact[1]=1;
    
    int epochs;cin>>epochs;
    while(epochs--){
        ll n;cin>>n;
        cout<<factMod(n)<<"\n";
    }

    return 0;
}