#include #if __has_include() #include using namespace atcoder; #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using mint = modint998244353; int main() { int n; string s; cin >> n >> s; vector dp(n+1); dp[0] = 1; rep(i, n) { int m = n-i; vector old(m); swap(dp, old); if (s[i] == '1') { rep(j, m) dp[j] = old[j]*(n-i-j); } else { rep(j, m) dp[j] = old[j+1]*(j+1); mint sum; rep(j, m) { sum += old[j]; dp[j] += sum; } } } mint ans = dp[0]; cout << ans.val() << '\n'; return 0; }