#include int main () { int n = 0; char s[4001] = ""; int res = 0; long long ans = 0LL; long long mod_num = 998244353LL; long long dp[4000][4000] = {}; long long pow2[4000] = {}; int cnt[4000] = {}; res = scanf("%d", &n); res = scanf("%s", s); if (n <= 1) { printf("%d\n", (int)(s[0]-'0')); return 0; } pow2[0] = 1LL; for (int i = 1; i < n; i++) { pow2[i] = (pow2[i-1]*2LL)%mod_num; } if (s[0] == '1') { dp[0][0] = 1LL; ans += pow2[n-2]; } for (int i = 1; i < n; i++) { for (int j = i; j >= 0; j--) { if (s[j] == '1') { long long tmp = pow2[j]; if (j > 0) { tmp += mod_num-dp[j-1][i-j]; } dp[i][i-j] = tmp%mod_num; tmp *= pow2[i-j]; tmp %= mod_num; if (i < n-1) { tmp *= pow2[n-2-i]; } ans += tmp%mod_num; } } for (int j = 0; j < n; j++) { dp[i][j] += 2LL*dp[i-1][j]; dp[i][j] %= mod_num; } } printf("%lld\n", ans%mod_num); return 0; }