import sys input = sys.stdin.readline mod=int(input()) now=-1 ANS=-1 for i in range(mod-1,0,-1): now=now*i%mod ANS+=now ANS%=mod print(ANS)