import io.StdIn._
object Main extends App {
    val n = readInt
    val as = readLine.split(" ").map(_.toInt)
    
    val sanbai = as ++ as.map(_-1) ++ as.map(_+1)
    val number = sanbai.distinct
    println(number.map(n => sanbai.count(_==n)).max)
}