fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map{it.toInt()}
    val nums = mutableMapOf<Int, Int>()

    aa.forEach {
        nums[it] = (nums[it] ?: 0) + 1
    }

    var max = 0
    nums.keys.forEach {
        val sum = (nums[it-1] ?: 0) + nums[it]!! + (nums[it+1] ?: 0)
        if (sum > max) max = sum
    }

    println(max)
}