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 arrUniq: Array[Int] = arrInt.distinct
  // val (minV, maxV) = (arrUniq.min, arrUniq.max)
  val lst: Array[List[Int]] = for (x <- arrInt ) yield List(x - 1, x, x + 1)
  val lstUniq: Array[Int] = lst.flatten.distinct
  // map if contain x 1 else 0
  val map = scala.collection.mutable.Map[Int,Int]()
  for (x <- lstUniq) {
     map.put(x, lst.map(x1 => if(x1.contains(x)) 1 else 0).sum)
  }
  println(map.maxBy(_._2)._2)
}