import io.StdIn._
object Main extends App {
    val n = readInt
    val as = readLine.split(" ").map(_.toInt)
    
    val number = as.distinct
    val counts = number.map(n => as.filter(a => n-1 == a || n == a || n+1 == a).length)

    println(counts.max)
}