#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long LL;
const long long mod = 1e9 + 7;
long long ax[1000010];
int main(void) {
long long ans = 1;
long long gg1 = 1;
long long tot = 1;
ax[3] = 1;
long long maxx = 2;
for (long long i = 4; i <=1000000; i++) {
gg1 = gg1 + (maxx + 1)*maxx / 2;
gg1 = (gg1%mod + mod) % mod;
tot += gg1;
maxx += 1;
ans = (ans + tot) % mod;
ax[i] = ans;
}
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
printf("%lld\n", ax[n]);
}
return 0;
}