mod = 998244353 table_len = 10 ** 5 + 10 fac = [1, 1] for i in range(2, table_len): fac.append(fac[-1] * i % mod) finv = [0] * table_len finv[-1] = pow(fac[-1], mod - 2, mod) for i in range(table_len - 1, 0, -1): finv[i - 1] = finv[i] * i % mod def comb(n, k): if k < 0 or n < 0 or n - k < 0: return 0 return fac[n] * finv[k] % mod * finv[n - k] % mod n = int(input()) s = input() c0 = s.count('0') c1 = n - c0 dp = [[0] * (n + 1) for i in range(n + 1)] dp[0][0] = 1 for i in range(n): for j in range(n + 1): if i + 2 <= n and j + 1 <= n: dp[i + 2][j + 1] = (dp[i + 2][j + 1] + dp[i][j] * (i + 1)) % mod if j + 1 <= n: dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * (i - j)) % mod dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * j) % mod res = 0 for eq0 in range(c0 + 1): for eq1 in range(c1 + 1): pos_eq = comb(c0, eq0) * comb(c1, eq1) % mod * fac[eq0] % mod * fac[eq1] % mod num_eq = comb(c0 + c1, eq0) * comb(c0 + c1 - eq0, eq1) % mod pos_neq = dp[c0 - eq0 + c1 - eq1][c0 - eq0] pos_neq2 = fac[c0 - eq0] * fac[c1 - eq1] % mod res += pos_eq * num_eq % mod * pos_neq % mod * pos_neq2 % mod res %= mod print(res)