传送阵
S[n] = n*(n+1)(2n+1)/6 = 1(2)+2(2)+3(2)+4(2)+5(5)+6(2)+…+n(2)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
const int MX=1e5+9;
ll n,a[MX];
ll exgcd(ll a,ll b,ll &x,ll &y){
if( b==0 ){
x=1;
y=0;
return a;
}
ll res=exgcd(b,a%b,y,x);
y-=(a/b)*x;
return res;
}
ll niyuan(ll a,ll mod){
ll x,y;
ll d=exgcd(a,mod,x,y);
return (x%mod+mod)%mod;
}
int main()
{
freopen("input.txt","r",stdin);
while( ~scanf("%lld",&n) ){
n=n%mod;
ll ans=n*(n+1)%mod*(2*n+1)%mod*niyuan(6,mod)%mod;
printf("%lld\n",ans);
}
return 0;
}