import std; void main () { int N = readln.chomp.to!int; string S = readln.chomp; solve(N, S); } void solve (int N, string S) { /* dp的に解く 新しい区間を導入したとき、そこで切るか切らないかの2択 */ bool ok = false; foreach (c; S) if (c == '1') ok = true; if (!ok) { writeln(0); return; } const int MOD = 998244353; long ans = 1; // カットしないやつ // 右と左の0を削除 foreach (i, c; S) if (c == '1') { S = S[i..$]; break; } foreach_reverse (i, c; S) if (c == '1') { S = S[0..i+1]; break; } writeln(S); int len = 0; int cur = 1; while (true) { if (cur == S.length) { break; } if (S[cur] == '1') { ans *= len+2; ans %= MOD; len = -1; } len++; cur++; } writeln(ans); } long modPow (long a, long x, ref const long MOD) { import std.exception : enforce; enforce(0 <= x, "x must satisfy 0 <= x"); enforce(1 <= MOD, "MOD must satisfy 1 <= MOD"); enforce(MOD <= int.max, "MOD must satisfy MOD*MOD <= long.max"); // normalize a %= MOD; a += MOD; a %= MOD; long res = 1L; long base = a; while (0 < x) { if (0 < (x&1)) (res *= base) %= MOD; (base *= base) %= MOD; x >>= 1; } return res % MOD; } T modPow (T, X, Y) (T a, X x, ref const Y MOD) { import std.exception: enforce; enforce(0 <= x, "x must satisfy 0 <= x"); enforce(1 <= MOD, "MOD must satisfy 1 <= MOD"); // normalize a %= MOD; a += MOD; a %= MOD; T res = 1; T base = a; while (0 < x) { if (0 < (x&1)) (res *= base) %= MOD; (base *= base) %= MOD; x >>= 1; } return res % MOD; }