import scala.io.StdIn
import scala.collection.mutable.Map

object Main extends App {

  val n = StdIn.readLine.toInt
  val seq = StdIn.readLine.split(" ").map(_.toInt)

  val ans = {
    var map:Map[Int,Int] = Map()
    map.par
    var cnt = 0

    for(k <- seq) {
      if(map.contains(k)) {
        val v = map.get(k).get + 1
        if(v > k) cnt = cnt + 1
        else map.put(k, v)
      }
      else map = map + (k -> 1)
    }
    cnt + map.withFilter(e => e._1 != e._2).map(_._2).sum
  }

  println(ans)
}