program prob4
    implicit none
    integer, allocatable::a(:), c(:)
    integer::n, i, j, cnt
    read(*,*) n
    allocate(a(n),c(n))
    read(*,*) a
    c = 0
    cnt = 0
    do i = 1, n
        if(a(i) > n) then
            cnt = cnt + 1
        else
            c(a(i)) = c(a(i)) + 1
        end if
    end do
    do i = 1, n
        if(c(i) >= i) then
            cnt = cnt + c(i) - i
        else if(c(i) > 0) then
            cnt = cnt + c(i)
        end if
    end do
    write(*,*) cnt
    deallocate(a,c)
    stop
end program