program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans
    integer(int32), allocatable:: a(:), ind(:)
    read*, n
    allocate(a(n))
    read*, a(:)
    allocate(ind(n),source=0)
    ans=0
    do i = 1, n
        if (a(i) <= n) then
            ind(a(i))=ind(a(i))+1
        else
            ans=ans+1
        end if
    end do

    do i=1,n
        if (ind(i) >= i) then
            ans=ans+ind(i)-i
        else
            ans=ans+ind(i)
        end if
    end do
    print'(i0)', ans
end program name