N=int(input()) mod=10**9+7 X=(N*N*N-N)//6 Y=(N*N-N)//2 ans=X*N*pow(Y,mod-2,mod) ans%=mod print(ans)