## https://yukicoder.me/problems/no/2279 MOD = 998244353 def main(): N = int(input()) S = input() dp = [[0] * N for _ in range(N)] cum_dp = [[0] * N for _ in range(N)] dp[0][0] = int(S[0]) cum_dp[0][0] = int(S[0]) for i in range(1, N): for j in reversed(range(i)): if int(S[j + 1]) == 1: dp[i][i - 1 - j] = pow(2, j + 1, MOD) else: dp[i][i - 1 - j] = cum_dp[j][i - 1 - j] dp[i][i - 1 - j] += (cum_dp[i - 1][i - 1 - j] - cum_dp[j][i - 1 - j]) % MOD dp[i][i - 1 - j] %= MOD dp[i][i] = int(S[0]) for j in range(N): cum_dp[i][j] = (dp[i][j] + cum_dp[i - 1][j]) % MOD answer = 0 for i in range(N): weight = pow(2, i, MOD) answer += (weight * dp[-1][i]) % MOD answer %= MOD print(answer) if __name__ == "__main__": main()