"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const n = nextInt()
    const a = nextIntArray()
    let m = {}
    let maxVal = 0
    for(let val of a){
        if(!m[val]) m[val] = 1
        else m[val]++
        maxVal = Math.max(maxVal, val)
    }
    let cnt = {}

    for(let i = 0; i<= maxVal; i++){
        let curr = m[i] ? m[i] : 0
        let prev = m[i-1]? m[i-1] : 0
        let next = m[i+1]? m[i+1] : 0
        cnt[i] = curr + prev + next
    }
    let ans = 1
    for(let key of Object.keys(cnt)){
        ans = Math.max(ans, cnt[key])
    }
    console.log(ans)
}
Main()
