MOD=998244353
N=gets.to_i
D=gets.split.map(&:to_i)

data=Hash.new(0)
D.each do |d|
    data[d] += 1
end

flag=true
ary = data.sort
ans=1

ary.size.times do |i|
    key, value = ary[i]
    if key != i
        flag = false
        break
    end
    next if key == 0
    _, pre_value = ary[i-1]
    while value > 0
        ans = (ans * pre_value) % MOD
        value -= 1
    end
end
if flag
    puts ans
else
    puts 0
end
