function Main(input) {
    input = input.split("\n")
    const n = parseInt(input[0])
    var A = input[1].split(" ")
    
    var tmp = {}
    for (var i=0;i<100000;i++){
        tmp[i]=0
    }

    for (var i=0;i<n;i++){
        var a = parseInt(A[i])
        tmp[a-1]++
        tmp[a]++
        tmp[a+1]++
    }

    var ans = 0
    for (var i=0;i<100000;i++){
        ans = Math.max(ans,tmp[i])
    }
    
    console.log(ans)

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
