N = 10**6 mod = 998244353 fac = [1]*(N+1) finv = [1]*(N+1) for i in range(N): fac[i+1] = fac[i] * (i+1) % mod finv[-1] = pow(fac[-1], mod-2, mod) for i in reversed(range(N)): finv[i] = finv[i+1] * (i+1) % mod def cmb1(n, r, mod): if r <0 or r > n: return 0 r = min(r, n-r) return fac[n] * finv[r] * finv[n-r] % mod n = int(input()) B = list(map(int, input().split())) x = 0 o = 0 e = 0 for i, b in enumerate(B): if b != -1: x ^= b else: if i == 0 or i == n-1: o += 1 else: if (n-1)%2 == 0: e += 1 else: o += 1 ans = 0 if x == 0: ans = pow(2, o, mod)-1 ans *= pow(2, e, mod) ans %= mod else: for k in range(o+1): if k%2 == 0: continue ans += cmb1(o, k, mod)*pow(2, e, mod) ans %= mod print(ans)