fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = readLine()?.split(" ")?.map(String::toInt)?.sorted() ?: return
    val count = hashMapOf<Int, Int>()
    fun add(c: java.util.HashMap<Int, Int>, v: Int) {
        if (c.containsKey(v)) {
            c[v] = c[v]!! + 1
        } else {
            c[v] = 1
        }
    }
    a.forEach {
        add(count, it - 1)
        add(count, it)
        add(count, it + 1)
    }
    count.maxBy { it.value }?.let {
        println(it.value.toString())
    }
}