#include using namespace std; const int mod = 998244353; int n;string s; const int N = 3005; int dp[N][N],sm[N][N];//when you're in pos i,lst 0 is in pos j int main(){ //freopen("aspect.out","w",stdout); //freopen("aspect.in","r",stdin); scanf("%d",&n); cin>>s; s=" "+s; dp[0][0]=1; sm[0][0]=1; for(int i = 1;i<=n;i++){ if(s[i]=='1'){ for(int j = 0;j<=i;j++){ dp[i][j]=1ll*dp[i-1][j]*(i-j)%mod; sm[i][j]+=dp[i][j]; if(j>0)sm[i][j]+=sm[i][j-1]; sm[i][j]%=mod; } }else{ for(int j = 1;j<=i;j++){ dp[i][j]=sm[i-1][j-1]; if(j!=1)dp[i][j]+=1ll*dp[i-1][j-1]*(j-1)%mod; dp[i][j]%=mod; sm[i][j]+=dp[i][j]; sm[i][j]+=sm[i][j-1]; sm[i][j]%=mod; } } } printf("%d\n",sm[n][n]); }