program counting_of_trees
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer :: n, d(100000) = 0, a(0:100000) = 0, i
  integer(8) :: x = 1_8
  read(*,*) n
  read(*,*) d(1:n)
  do i = 1, n
    a(d(i)) = a(d(i))+1
  end do
  if (d(1) /= 0 .or. a(0) /= 1) then
    write(*,'(i0)') 0
    stop
  end if
  do i = 1, n
    x = mod(x*pow(int(a(i-1),8),a(i)),md)
  end do
  write(*,'(i0)') x
contains
  function pow(a,b) result(ret)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer :: k
    integer(8) :: ret, p
    ret = 1_8
    p = a
    k = b
    do while (k > 0)
      if (btest(k,0)) ret = mod(ret*p,md)
      p = mod(p*p,md)
      k = rshift(k,1)
    end do
  end
end program counting_of_trees