object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    val datA = readLine.split(" ").map(_.toInt)

    val scoreA = datA.groupBy(identity).map{ case (k, v) => (k, v.length) }
    val ans = scoreA.keys.map{ a => scoreA.getOrElse(a - 1, 0) + scoreA.getOrElse(a, 0) + scoreA.getOrElse(a + 1, 0)}.max
    println(ans)
  }
}
