#include using namespace std; using ll = long long; #include using namespace atcoder; using mint = modint998244353; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") int main() { int N; string S; cin >> N >> S; mint ans = 0; ll dp[3010]; for (ll k = 0; k < N; k++) { dp[0] = 1; for (int i = 1; i <= N; i++) { dp[i] = 0; } for (int i = 0; i < N; i++) { if (i - k < 0 || S.at(i - k) == '0') { for (int j = 0; j <= i; j++) { dp[i + 1] += dp[j]; } } else { for (int j = i - k + 1; j <= i; j++) { dp[i + 1] += dp[j]; } } dp[i + 1] %= mint::mod(); } ans += (mint(2).pow(N - 1) - dp[N]) * mint(2).pow(k); } cout << ans.val() << endl; }