"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let map = {};
    
    for(let i in A) {
        let plus = A[i] + 1;
        let raw = A[i];
        let minus = A[i] - 1;
    
        
        if(!map[plus]) {
            map[plus] = 1;
        } else {
            map[plus]++;
        }
        
        if(!map[raw]) {
            map[raw] = 1;
        } else {
            map[raw]++;
        }
        
        if(!map[minus]) {
            map[minus] = 1;
        } else {
            map[minus]++;
        }
    }
    
    let answer = 0;
    
    for(let key in map) {
        answer = Math.max(answer, map[key]);
    }
    
    // console.log(JSON.stringify(map));
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));