N=int(input()) if N==2: print(2) exit() mod=10**9+7 a=(N-1)*N*N//2 b=(N-1)*N*(2*N-1)//6 print((a-b)*2*pow(N-1,mod-2,mod)%mod)