# -*- coding: utf-8 -*-

numAns = 0

class Node:
    def __init__(self,init):
        self.addr = None
        self.boss = init
        self.subordinate = []
    def printBoss(self):
        print(self.boss)
    def showTree(self,tmp_node):
        print(self.addr,self.boss,self.subordinate)
        for sub in self.subordinate:
            # print("-",end="")
            tmp_node[sub-1].showTree(tmp_node)
    def findTree(self,N,relation,tmp_node):
        relation.append(self.addr)

        if N == len(relation):
            global numAns
            numAns = (numAns+1) % 1000000007
            
            relation.pop()
            return

        list = [True for i in range(N)]
        list[int(self.addr)-1] = False
        if self.boss is not None:
            list[int(self.boss)-1] = False
        for sub in self.subordinate:
            list[int(sub)-1] = False
        for rel in relation:
            list[int(rel)-1] = False
        
        for i in range(len(list)):
            if list[i] is True:
                tmp_node[i].findTree(N,relation,tmp_node)
        relation.pop()
                
        
def input_boss(boss):
    N = input()
    for i in range(int(N)-1):
        boss.append(input())
    return N

def make_tree(nodes,boss):
    for num in boss:
        nodes.append(Node(num))

    nodes.insert(0,Node(None))
    nodes[0].addr = 1

    for i in range(1,len(nodes)):
        nodes[i].addr = i+1
        tmp_boss = int(nodes[i].boss)-1
        nodes[tmp_boss].subordinate.append(i+1)
    
    # for node in nodes:
    #     print(node.addr,node.boss,node.subordinate)

if __name__ == '__main__':

    boss =[]
    
    N = input_boss(boss)

    nodes = []
    make_tree(nodes,boss)

    # nodes[0].showTree(nodes)
    for i in range(len(nodes)):
        relation = []
        nodes[i].findTree(int(N),relation,nodes)
    
    print(numAns)