Start: Feb, 21, 2019 12:00:00
2018-2019 ACM集训队冬季集训第二次考核
End: Feb, 21, 2019 17:00:00
Time elapsed:
Time remaining:

Problem_ID: C
Result: Accepted
Time: 32ms
Memory: 8904kB
Author: 2017212212172
In contest: 1261

#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;
}