def precompute_factorials(n, mod):
factorials = [1] * (n + 1)
inv_factorials = [1] * (n + 1)
for i in range(1, n + 1):
factorials[i] = (factorials[i - 1] * i) % mod
inv_factorials[n] = pow(factorials[n], -1, mod)
for i in range(n - 1, 0, -1):
inv_factorials[i] = (inv_factorials[i + 1] * (i + 1)) % mod
return factorials, inv_factorials
def binomial_coefficient(n, k, mod, factorials, inv_factorials):
numerator = factorials[n]
denominator = (factorials[k] * factorials[n - k]) % mod
denominator_inverse = inv_factorials[k] * inv_factorials[n - k] % mod
return (numerator * denominator_inverse) % mod
def calculate_formula(n, mod, factorials, inv_factorials):
result = 0
for i in range(1, n + 1):
coefficient = binomial_coefficient(n, i, mod, factorials, inv_factorials)
result = (result + (coefficient * factorials[i - 1] * factorials[n - i]) % mod) % mod
return result
n = int(input())
mod = 998244353
factorials, inv_factorials = precompute_factorials(n, mod)
result = calculate_formula(n, mod, factorials, inv_factorials)
print(result)