object Main extends App {
	val N = scala.io.StdIn.readInt
	val A = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	val map = scala.collection.mutable.Map[Int,Int]()

	for(x <- A){
		map.put(x - 1, map.getOrElse(x - 1, 0) + 1)
		map.put(x    , map.getOrElse(x    , 0) + 1)
		map.put(x + 1, map.getOrElse(x + 1, 0) + 1)
	}
	println(map.maxBy(_._2)._2)
}
