#include #define MOD 998244353 int a; long long int check[1510][3010][4]; char x[1510]; long long int func(int s, int t, int type) { if(s>a) { if(t<=0&& (-t)%2==0) return 1; else return 0; } if(check[s][t+1500][type]!=-1) return check[s][t+1500][type]; long long int ans; if(type==0) // last = 0 { long long int s1 = func(s+1,t+1,0); long long int s2 = func(s+1,t,1); if(x[s]=='0') s2 = 0; if(x[s]=='1') s1 = 0; ans = (s1+s2)%MOD; } if(type==1) // last = 01 { long long int s1 = func(s+1,t-1,2); long long int s2 = func(s+1,t,1); if(x[s]=='0') s2 = 0; if(x[s]=='1') s1 = 0; ans = (s1+s2)%MOD; } if(type==2) // last = 010 { long long int s1 = func(s+1,t+1,0); long long int s2 = func(s+1,t,1); if(x[s]=='0') s2 = 0; if(x[s]=='1') s1 = 0; ans = (s1+s2)%MOD; } return check[s][t+1500][type] = ans; } int main() { scanf("%d",&a); for(int i=0;i<=1500;i++) for(int j=0;j<=3000;j++) for(int k=0;k<=2;k++) check[i][j][k] = -1; scanf("%s",x+1); long long int ans = 0; for(int i=1;i<=a;i++) { if(x[i]=='1') continue; ans += func(i+1,1,0), ans %= MOD; if(x[i]=='0') goto u; } ans++, ans %= MOD; u:; printf("%lld",ans); }