"use strict";
    
const main = arg => {
  let NumAmount = arg.split("\n")[0]*1;
  let Nums = arg.split("\n")[1].split(" ");  
  let ans = 0;
  let numObj = new Map();
  Nums.forEach(n=>{
    if(numObj[n] == null){
  		numObj[n] = 1;
    }else {
    	numObj[n]++;
    }
    if(numObj[n*1+1] == null){
  		numObj[n*1+1] = 1;
    }else {
    	numObj[n*1+1]++;
    }
    if(numObj[(n-1)*1] == null){
  		numObj[(n-1)*1] = 1;
    }else {
    	numObj[(n-1)*1]++;
    }
  });
  let maxNum = 0;
  for(let n in numObj){
  	if(maxNum < numObj[n]){
      maxNum = numObj[n];
	}
  }
  console.log(maxNum);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
