program example
    implicit none

    integer(8) N,i,j
    integer(8),allocatable :: A(:),B(:)

    read(*,*) N

    allocate(A(1:N),B(1:N))

    B=0

    read(*,*) A(2:N)

    do i=1,N

        do j=i+1,N

            if(i==A(j)) then
                B(i)=B(i)+1
            end if
        end do
    end do

    do i=1,N
        write(*,*) B(i)
    end do
end program example
