n=int(input()) P=[1] for i in reversed(range(1,n)): P.append(P[-1]*i) P[-1]%=n print((sum(P)*pow(P[-1],-1,n))%n)