intqpow(int a, int b) { int t = 1; while(b != 0) { if(b & 1)t = t * a % mod; a = a * a % mod; b >>= 1; } return t; }
intinv(int x) { returnqpow(x, mod - 2); }
intA(int n, int m) { return fac[n] % mod * ifac[n - m] % mod; }
intcalc(int x) { int sum = 0, len = n / x; for(int d = 1; d <= x; d++) { int res = 1; for(int i = 0, j = x - 1; i < len; i++, j += x - d) res = res * A(j, x - 1) % mod * x % mod; sum = (sum + res) % mod; } return sum; }
signedmain() { int sum = 0; cin >> n; int ans = 0; fac[0] = ifac[0] = 1; for(int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod; for(int i = 1; i <= n; i++) ifac[i] = inv(fac[i]); for(int i = 1; i < n; i++) { if(n % i)continue; ans = (ans + calc(i)) % mod; } ans = (ans + fac[n] + mod) % mod; cout << ans; return0; }