import sys
input = sys.stdin.readline

sys.setrecursionlimit(10**7)

class Bit_indexed_tree():
    def __init__(self, LEN):
        self.BIT = [0]*(LEN+1) # 1-indexedなtree. 配列BITの長さはLEN+1にしていることに注意。
        self.LEN = LEN

    def update(self,v,w): # index vにwを加える
        while v<=self.LEN:
            self.BIT[v]+=w
            v+=(v&(-v)) # v&(-v)で、最も下の立っているビット. 自分を含む大きなノードへ. たとえばv=3→v=4

    def getvalue(self,v): # [1,v]の区間の和を求める
        ANS=0
        while v!=0:
            ANS+=self.BIT[v]
            v-=(v&(-v)) # 自分より小さい自分の和を構成するノードへ. たとえばv=14→v=12へ
        return ANS

    def bisect_on_BIT(self,x): # [1,ind]の和がはじめてx以上になるindexを探す

        if x<=0:
            return 0
        
        ANS=0
        h=1<<((self.LEN).bit_length()-1) # LEN以下の最小の2ベキ
        while h>0:
            if ANS+h<=self.LEN and self.BIT[ANS+h]<x:
                x-=self.BIT[ANS+h]
                ANS+=h
            h//=2

        return ANS+1 # LENまでの和がx未満のとき, LEN+1を返すことに注意


N=int(input())
A=list(map(int,input().split()))

E=[[] for i in range(N)]
Parent=[-1]*N
Child=[[] for i in range(N)]

for i in range(1,N):
    x=A[i-1]

    Parent[i]=x
    Child[x].append(i)

BIT=Bit_indexed_tree(N+10)
ANS=[0]

def dfs(x):
    ANS[0]+=BIT.getvalue(x+1)
    BIT.update(x+1,1)
    for c in Child[x]:
        dfs(c)
    BIT.update(x+1,-1)

dfs(0)
print(ANS[0])