#include using namespace std; const int MAXN = 2001, MOD = 998244353; int n, dp[MAXN][MAXN], sum[MAXN][MAXN]; string s; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> s; s = ' ' + s; dp[0][n] = 1; for(int i = 0; i <= n; ++i) { for(int j = n - i; j >= 0; --j) { sum[i][j] = (sum[i][j] + sum[i][j + 1]) % MOD; dp[i][j] = (dp[i][j] + sum[i][j]) % MOD; if(i == n) { continue; } if(s[i + 1] == '1' && j) { dp[i + 1][j - 1] = (dp[i + 1][j - 1] + 1ll * j * dp[i][j] % MOD) % MOD; }else if(s[i + 1] == '0') { dp[i + 1][j] = (dp[i + 1][j] + 1ll * dp[i][j] * (n - i - j) % MOD) % MOD; if(j) { sum[i + 1][j - 1] = (sum[i + 1][j - 1] + dp[i][j]) % MOD; } } } } cout << dp[n][0]; return 0; }