N = int(input()) S = input() P = 998244353 ans = 0 for i in range(1,N + 1): dp = [0] * (N + 2) U = [0] * (N + 2) dp[0] = 1 for j in range(N + 1): if j > 0: U [j] += U[j-1] dp[j] = U[j] if i + j <= N and S[-(i+j)] == "1": U[i + j] -= dp[j] if j < N + 1: U[j + 1] += dp[j] #print(dp[j]) last = U[-1] ans += pow(2,i-1,P) * (pow(2,N -1,P) - last) % P print(ans % P)