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