N = int(input()) B = list(map(int, input().split())) MOD = 998244353 ct = 0 for i in range(1, N-1): if B[i] == -1: ct += 1 a = B[0] b = B[-1] if a == b: if a >= 0: print(0) exit() ct += 1 print(pow(2, ct, MOD))