fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val r = readLine()!!.split(" ").map { it.toInt() }
    val cnt = mutableMapOf<Int, Int>()
    for(num in r) {
        for(j in (num-1..num+1)) {
            val tmp = (cnt[j]?:0)+1
            cnt[j] = tmp
        }
    }
    println(cnt.values.max())
}