n = int(input()) mod = pow(10, 9) + 7 even, odd = 0, 0 s = [0] * (n+1) s[1] = 1 if n == 1: print(n) exit() else: for i in range(2, n+1): s[i] = (i * s[i-1] + s[i-2]) % mod ans = (s[n] - s[n-2] + mod) % mod print(ans)