object Main extends App {
  val n: Int = io.StdIn.readLine().toInt
  val arr: Array[String] = io.StdIn.readLine().split(' ')
  val arrInt: Array[Int] = arr.map(str => str.toInt)
  val map = scala.collection.mutable.Map[Int,Int]()
  for (x <- arrInt ) {
    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)
}