import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) mod = 998244353 N = int(input()) parent = [-1] + [int(input())-1 for i in range(N-1)] edge = [[] for v in range(N)] for i in range(1,N): edge[parent[i]].append(i) depth = [0] * N deq = deque([0]) while deq: v = deq.popleft() for nv in edge[v]: depth[nv] = depth[v] + 1 deq.append(nv) res = 1 for v in range(1,N): res *= depth[v] res %= mod print(res)