R=range P=int(input()) a=0 f=1 for i in R(P): u=1 e=P-2 p=f while e: if e&1:u=u*p%P p=p*p%P e>>=1 a+=u;f=f*(i+1)%P print(a%P)