n=int(input()) m = 10**9+7 res=1 while n > 1: res=(res*(m-1 if (n//m)%2==1 else 1))%m for i in range(2, n%m+1): res= (res*i)%m n //=m print(res%m)