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