MOD = 998244353 N = int(input()) if N == 0: print(0) else: # Compute factorial mod MOD fact = 1 for i in range(2, N + 1): fact = fact * i % MOD # Compute S1, S2, S3 using Fermat's theorem S1 = 0 S2 = 0 S3 = 0 for i in range(1, N + 1): inv_i = pow(i, MOD - 2, MOD) S1 = (S1 + inv_i) % MOD inv_i_sq = inv_i * inv_i % MOD S2 = (S2 + inv_i_sq) % MOD inv_i_cu = inv_i_sq * inv_i % MOD S3 = (S3 + inv_i_cu) % MOD # Compute the sum using the derived formula term1 = pow(S1, 3, MOD) term2 = 3 * pow(S1, 2, MOD) % MOD term3 = S1 % MOD term4 = (3 * S2) % MOD term4 = term4 * ((S1 + 1) % MOD) % MOD term5 = (2 * S3) % MOD sum_total = (term1 + term2 + term3) % MOD sum_total = (sum_total - term4) % MOD sum_total = (sum_total + term5) % MOD # Multiply by fact[N] and take mod ans = sum_total * fact % MOD print(ans)