#include using namespace std; using ll = long long; const int N = 2010, mod = 998244353; int n; ll dp[N][N], d[N]; string s; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> s, s = ' ' + s; dp[0][n] = 1; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { if (s[i] == '0') { (dp[i][j] += dp[i - 1][j] * (n - i + 1 - j) % mod) %= mod; (d[0] += dp[i - 1][j]) %= mod; (d[j] += mod - dp[i - 1][j]) %= mod; } else { if (j) (dp[i][j - 1] += dp[i - 1][j] * j % mod) %= mod; } } (dp[i][0] += d[0]) %= mod; for (int j = 1; j <= n; j++) d[j] += d[j - 1], (dp[i][j] += d[j]) %= mod; fill(d, d + n + 1, 0); } cout << dp[n][0]; return 0; }