N = int(input()) mod = 10**9+7 ls = [0,1] lssum = [0,1] for i in range(2,N+1): v = lssum[i-1]*i ls.append(v%mod) lssum.append((lssum[i-2]+v)%mod) print(ls[-1])