fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val M = java.util.HashMap<Int, Long>()
    A.forEach { M[it] = M.getOrElse(it, { 0 }) + 1 }
    var ans = 1L
    M.asIterable().forEach {
        val x = it.key
        val c = M.getOrElse(x - 1, { 0 }) +
                M.getOrElse(x + 0, { 0 }) +
                M.getOrElse(x + 1, { 0 })
        if (ans < c) ans = c
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
