import java.util.*

fun main(strs: Array<String>) {
    var scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    scanner.useDelimiter("\\s|\\n")
    val array = Array(100001, { k -> 0})
    for (i in 0 until n) {
        val a = scanner.nextInt()
        array[a]++
    }
    var maxVal = 0
    for(i in 1 until 100000) {
        val value = array[i-1] + array[i] + array[i+1]
        if(value > maxVal) {
            maxVal = value
        }
    }
    println(maxVal)
}