local mfl, mce = math.floor, math.ceil local mod = 998244353 local function bmul(x, y) local x0, y0 = x % 31596, y % 31596 local x1, y1 = mfl(x / 31596), mfl(y / 31596) return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod end local function modpow(src, pow) local res = 1 while 0 < pow do if pow % 2 == 1 then res = bmul(res, src) pow = pow - 1 end src = bmul(src, src) pow = mfl(pow / 2) end return res end local n = io.read("*n") local b = {} for i = 1, n do b[i] = io.read("*n") end local c2 = 0 local bias, change = 0, 0 if b[1] == 1 then bias = 1 elseif b[1] == -1 then change = change + 1 end local ret = 1 n = n - 1 for i = 1, n do local mul = n + 1 - i local div = i while mul % 2 == 0 do c2 = c2 + 1 mul = mfl(mul / 2) end while div % 2 == 0 do c2 = c2 - 1 div = mfl(div / 2) end if 0 == c2 then -- print("!", i) if b[i + 1] == 1 then bias = 1 - bias elseif b[i + 1] == -1 then change = change + 1 end else if b[i + 1] == -1 then ret = (ret + ret) % mod end end end -- print(change, bias) if change == 0 then print(bias) else print(bmul(ret, modpow(2, change - 1))) end