fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map(String::toInt).sorted()

    val map = mutableMapOf<Int, Int>()
    for (a in an) {
        if (0 <= a - 1) {
            map[a - 1] = (map[a - 1] ?: 0) + 1
        }
        map[a] = (map[a] ?: 0) + 1
        map[a + 1] = (map[a + 1] ?: 0) + 1
    }

    map.maxBy { it.value }!!.value.let(::println)


}
