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 p = 2 C = [[0]*(p+1) for i in range(p+1)] #C[n][k] > nCk for i in range(p+1): for j in range(i+1): if j == 0 or j == i: C[i][j] = 1 else: C[i][j] = C[i-1][j-1]+C[i-1][j] def cmb2(n, k, p): ret = 1 while n > 0: ni = n%p ki = k%p ret *= C[ni][ki] ret %= p n //= p k //= p return ret n = int(input()) B = list(map(int, input().split())) x = 0 o = 0 e = 0 for i, b in enumerate(B): if b != -1: if cmb2(n-1, i, 2)%2 == 1: x ^= b else: if cmb2(n-1, i, 2)%2 == 1: o += 1 else: e += 1 ans = 0 if x == 0: for k in range(o+1): if k%2 == 0: continue ans += cmb1(o, k, mod)*pow(2, e, mod) ans %= mod else: for k in range(o+1): if k%2 == 1: continue ans += cmb1(o, k, mod)*pow(2, e, mod) ans %= mod print(ans)