N = int(input()) A = input() MOD = 998244353 dp = [1, 0, 0, 0] for c in A: nxt = [0] * 4 for s in range(4): if not dp[s]: continue L, R = s // 2, s % 2 if not (c == '1' and not R): ns = L * 2 | (R or c == '0') nxt[ns] = (nxt[ns] + dp[s]) % MOD if not (c == '0' and not L): ns = (L or c == '1') * 2 | R nxt[ns] = (nxt[ns] + dp[s]) % MOD dp = nxt print(sum(dp) % MOD)