local n=io.read("*n")
local verte={}
local flag=true
for i=1,n do
    local x=io.read("*n")
    if (i==1 and x>0) or (i>1 and x==0) then
        flag=false
    end
    verte[x]=(verte[x] or 0)+1
end

if not flag then
    print(0)
else
    local tree=1
    local mod=998244353
    for x,_ in pairs(verte) do
        if x+1<=#verte then
            if not verte[x] or not verte[x+1] then
                print(0)
                return
            end
            for i=1,verte[x+1] do
                tree=tree*verte[x]%mod
            end
        end
    end
    print(tree)
end