n = int(input()) def f2(x): return x * (x + 1) * (2 * x + 1) // 6 def f1(x): return x * (x + 1) // 2 def f(x): return (f2(x) + f1(x)) // 2 MOD = 10 ** 9 + 7 ans = f(n - 1) * 2 * pow(n - 1, -1, MOD) % MOD print(ans)