PROBLEM LINK:
Author: sourav472
Tester: sourav472
Editorialist: sourav472
DIFFICULTY:
CAKE WALK
PREREQUISITES:
Basic Mathematics
EXPLANATION:
Nth term of the series = ((N-1)^2 + N^3). For larger value of N, the Nth term modulo (10^9 + 7).
SOLUTIONS:
Setter's Solution & Tester's Solution
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define dfor(i,a,b) for(ll i=(a);i<(b);i++)
#define rfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define pii pair<ll,ll>
#define vi vector<ll>
#define vpii vector<pii>
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define fast ios_base::sync_with_stdio( false );cin.tie(NULL);
const ll mod = (ll)(1e9+7);
int main() {
fast
ll t;
cin>>t;
while(t--)
{
ll n,ans;
cin>>n;
ans = ((n-1)*(n-1)) + (n*n*n);
ans = ans%mod;
cout<<ans<<"\n";
}
return 0;
}