fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val count = mutableMapOf<Int,Int>()
    readLine()!!.split(" ")
        .map { it.toInt() }
        .forEach { count[it] = count.getOrElse(it, {0}) + 1 }
    var ans = 0
    for (key in 0..100000) {
        ans = Math.max(ans, (count[key - 1] ?: 0) + (count[key] ?: 0) + (count[key + 1] ?: 0))
    }
    println(ans)
}