N = int(input()) M = 1000000007 print((N*(N+1)*(M+1)//3) % M)