#include<bits/stdc++.h>
#define identity_imbalance ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(0)
#define endl "\n"
#define ll long long
#define pi 3.14159265358979323846
using namespace std;
bool pr(int n){
if(n<=1)
return false;
for(int i=2;i*i<=n;i++){
if(n%i==0)
return false;
}
return true;
}
ll fact(ll n ){
ll m=1e9+7;
if (n<=1)
return 1;
else
return (n*fact(n-1))%m;
}
int main() {
identity_imbalance;
int t;
cin>>t;
ll m=1e9+7;
while(t--){
ll n ;
cin>>n;
ll c=0;
vector<ll>v;
for(int i=2;i<=n;i++){
if(pr(i)==true)
v.push_back(i);
}
for(int i=v[0];i<=v[v.size()-1];i++){
if(n==i)
(c++)%m;
else c+=((fact(n)/(fact(i)*fact(n-i)))%m);
}
cout<<c%m<<endl;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBpZGVudGl0eV9pbWJhbGFuY2UgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSksY2luLnRpZShOVUxMKSxjb3V0LnRpZSgwKQojZGVmaW5lIGVuZGwgIlxuIgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHBpIDMuMTQxNTkyNjUzNTg5NzkzMjM4NDYKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKYm9vbCBwcihpbnQgbil7CiAgaWYobjw9MSkKICByZXR1cm4gZmFsc2U7CiAgZm9yKGludCBpPTI7aSppPD1uO2krKyl7CiAgICBpZihuJWk9PTApCiAgICByZXR1cm4gZmFsc2U7CiAgfQogIHJldHVybiB0cnVlOwp9CmxsIGZhY3QobGwgbiApewogIGxsIG09MWU5Kzc7CmlmIChuPD0xKQogICAgICAgIHJldHVybiAxOwogICAgZWxzZQogICAgICAgIHJldHVybiAobipmYWN0KG4tMSkpJW07Cn0KaW50IG1haW4oKSB7CiAgICBpZGVudGl0eV9pbWJhbGFuY2U7CiAgICAgaW50IHQ7CiAgICAgY2luPj50OwogICAgIGxsIG09MWU5Kzc7CiAgICAgd2hpbGUodC0tKXsKICAgICAgbGwgbiA7CiAgICAgIGNpbj4+bjsKICAgICAgbGwgYz0wOwogICAgICB2ZWN0b3I8bGw+djsKICAgICAgZm9yKGludCBpPTI7aTw9bjtpKyspewogICAgICAgIGlmKHByKGkpPT10cnVlKQogICAgICAgICAgdi5wdXNoX2JhY2soaSk7CiAgICAgICAgfQogICAgICAgIGZvcihpbnQgaT12WzBdO2k8PXZbdi5zaXplKCktMV07aSsrKXsKICAgICAgICAgIGlmKG49PWkpCiAgICAgICAgICAoYysrKSVtOwogICAgICAgICBlbHNlIGMrPSgoZmFjdChuKS8oZmFjdChpKSpmYWN0KG4taSkpKSVtKTsKICAgICAgICB9CiAgICAgIGNvdXQ8PGMlbTw8ZW5kbDsKICAgICB9CiAgICByZXR1cm4gMDsKfQ==