import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### ans = 0 mod = 998244353 n = ni() s = [int(i) for i in input()] for k in range(1, n+1): dp0 = [0] * (n+1) dp0[0] = 1 dp1 = [0] * (n+1) rui0 = [0] * (n+1) rui0[0] = 1 rui1 = [0] * (n+1) for i in range(1, n+1): if i-k >= 0 and s[i-k]: dp1[i] = (rui0[i-k]+rui1[i-1])%mod dp0[i] = (rui0[i-1]-rui0[i-k])%mod else: dp1[i] = rui1[i-1] dp0[i] = rui0[i-1] rui0[i] = (rui0[i-1] + dp0[i])%mod rui1[i] = (rui1[i-1] + dp1[i])%mod ans += dp1[-1] * pow(2, k-1, mod)%mod ans %= mod #print(dp1[-1]) print(ans)