import bisect n=int(input()) C=list(map(int,input().split())) mod=998244353 c1=bisect.bisect_left(C,0) c2=n-bisect.bisect_right(C,0) ans=1 if c1>0: ans*=pow(2,c1-1,mod) if c2>0: ans *= pow(2, c2 - 1, mod) ans%=mod if c1>0 and c2>0: ans*=2 ans*=pow(3,n-c1-c2,mod) ans%=mod print(ans)