program example
    implicit none

    integer(8) :: N,i,j,k,l=1,C
    integer(8),allocatable :: A(:),B(:)

    read(*,*) N

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

!    do j=1,N

!        B=findloc(A,value=j)
!        write(*,*) B 
!        write(*,*) size(B)
!    end do

    do i=1,N

        C=0

        do j=i+1,N

            if(i==A(j)) then
                C=C+1
            end if
        end do
        write(*,*) C
    end do

end program example
