fun main(args: Array<String>) {
    abc072c()
}

fun abc072c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }
        .sorted()

    var left = 0
    var right = 0
    val answer = aList.map { a ->
        while (left < n && aList[left] < a - 1) left++
        while (right < n && aList[right] <= a + 1) right++
        right - left
    }.max()

    println(answer)
}
