## https://yukicoder.me/problems/no/2279 MOD = 998244353 def main(): N = int(input()) S = input() # あらかじめ2の冪乗を計算しておく pow2 = [0] * (N + 1) p = 1 for i in range(N + 1): pow2[i] = p p *= 2 p %= MOD 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] = pow2[j + 1] 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 = pow2[i] answer += (weight * dp[-1][i]) % MOD answer %= MOD print(answer) if __name__ == "__main__": main()