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).sorted

  val ans = {
    var c = 0
    var m = 0
    var t = 0
    for(i <- seq) {
      if(i == m) {
        if(c < m) c += 1
        else t += 1
      } else if (m != c) t += c
      else c = 1
    m = i
    }
    if(m != c) t + c else t
  }

  println(ans)
}
