#include const int Mod = 998244353; int main() { int i, N, num[2] = {}; char S[5001]; scanf("%d", &N); scanf("%s", S); for (i = 0; i < N; i++) num[S[i] - '0']++; int j, comb[5001][5001]; for (i = 1, comb[0][0] = 1; i <= N; i++) for (j = 1, comb[i][0] = 1, comb[i][i] = 1; j < i; j++) comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % Mod; int dp[5001][5001]; for (i = 2, dp[0][0] = 1, dp[1][0] = 0, dp[1][1] = 0; i <= N; i++) { for (j = 1; j <= i; j++) { dp[i][j] = ((long long)dp[i-2][j-1] * (i - 1) + (long long)dp[i-1][j-1] * (i - j) + (long long)dp[i-1][j] * j) % Mod; } } long long ans, fact[5001]; for (i = 1, fact[0] = 1; i <= N; i++) fact[i] = fact[i-1] * i % Mod; for (i = 1, ans = fact[N]; i <= num[0]; i++) { for (j = 1; j <= num[1]; j++) ans += (long long)comb[num[0]][i] * comb[num[1]][j] % Mod * dp[i+j][i] % Mod * fact[N-i-j] % Mod * fact[i] % Mod * fact[j] % Mod * comb[N][i+j] % Mod; } printf("%lld\n", ans % Mod); fflush(stdout); return 0; }