import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  br.readLine()

  fun MutableMap<Int, Int>.putOrUpdate(key: Int) {
    if(this.containsKey(key)) this.put(key, this.get(key)!!.plus(1))
    else this.put(key, 1)
  }

  val map: MutableMap<Int, Int> = mutableMapOf()
  val a = br.readLine().split(" ").map { it.toInt() }
  for(key in a) {
    map.putOrUpdate(key)
  }

  val ans = map.keys.fold(0L) { acc, k ->
    val v: Int = map.get(k)!!
    when {
      k == v -> acc
      k >  v -> acc + v
      else   -> acc + (v - k)
    }
  }

  println(ans)
}