import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(input()) a = list(map(int, input().split())) ls = [] from collections import deque l = deque() flg = False left = True right = False seen0 = False for num in a: if num==0: seen0 = True if l: if flg: left = False ls.append(list(l)) l = [] flg = False elif (num==2 or num==-2) and flg: ls.append(list(l)) if seen0: left = False while abs(l[0])!=2: l.popleft() l.popleft() l.append(num) flg = True elif (num==2 or num==-2): l.append(num) flg = True else: if seen0: left = False l.append(num) if l: ls.append(list(l)) right = True M = 998244353 inv2 = pow(2, M-2, M) invs = [None]*(n+10) invs[0] = 1 for i in range(1, n+10): invs[i] = invs[i-1]*inv2 invs[i] %= M def sub(l, left=False, right=False): if 2 in l: ind = l.index(2) flg2 = True else: ind = l.index(-2) flg2 = False e0 = inv2 if (ind>0 or not left) else 1 o0 = 0 e1 = inv2 if (ind