#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("assign.in","r",stdin);
	freopen("assign.out","w",stdout);
	int t;
	cin>>t;
	while(t--){
	int n;
	long long ans=0;
	cin>>n;
	for(int i=1;i<n;i++){
		ans+=(n-1)*n+1;
		ans%=1000000007;
	}cout<<ans;
	}
}
